I have problem with this script. I don't know how can I save variable from script to php in the same script. document.write(x) doesn't work.
I need variable "total" and "val2" from script save to php variable and use in calculation "result".
<script>
function updateDue() {
$('#myTable tr').each(function(){
var total = parseFloat($(this).find('.num2').val());
var val2 = parseFloat($(this).find('.num1').val());
// to make sure that they are numbers
if (!total) {
total = 0;
}
if (!val2) {
val2 = 0;
}
var ansD = $(this).find(".remainingval");
ansD.val(<?php
$total= "..";
$val2="..";
$result=((strtotime($total) - strtotime($val2))/3600);
echo ($result);
?>);
});
}
</script>
Do you have some idea ? Thank you very much.