You just have a quoting issue. :
$UpdateText="updateReTotal(Tills,'pos_cash','{$till->till_id}');updateVariance('{$till->till_id}')";
echo '<script type="text/javascript">'
, "testFunctionForUpdateTotal('".$UpdateText."');"
, '</script>';
This is a good example of why you should avoid using echo
statements to output HTML. PHP is designed to allow you to embed PHP inside of your HTML and you should take advantage of that:
$UpdateText="updateReTotal(Tills,'pos_cash','{$till->till_id}');updateVariance('{$till->till_id}')";
?>
<script type="text/javascript">
testFunctionForUpdateTotal('<?= $UpdateText; ?>');
</script>';
5
solved can we use php variable in javascript and javascript variable in php code?