How can I use the php value in jQuery ?, what I do is pull the watt rate out of the database using php as follows and save in $ vatrate:
$sqlv = <<<SQL SELECT * FROM `vatrate` WHERE id='1' SQL; if(!$resultv = $db->query($sqlv)){ die('There was an error running the query [' . $db->error . ']'); } while($rowv = $resultv->fetch_assoc()){ $vatrate = $rowv['vatrate']; } ?>
Then I have a jQuery script that concatenates all the result lines and puts them in a range.
<script> $(document).ready(function() { $('input').on('keyup', function() { var rawValue, grandtotal = 0; $('span[id^="linetotal"]').each(function(i, elem) { rawValue = $.trim($(this).text()); if (rawValue == '') rawValue = 0; grandtotal += parseFloat(rawValue); }); $('#grandtotal').text(grandtotal); }); }); </script>
But now I'm not sure how to refer to the $ vatrate value declared in php in jQuery so that I can get the price + wat. VAT is a sales tax for those who are not in the UK :).
source share