-1
我對此腳本有問題。我不知道如何將腳本中的變量從腳本保存到php中。 document.write(x)不起作用。從腳本到腳本內部PHP代碼的變量
我需要變量「total」和「val2」從腳本保存到php變量並用於計算「結果」。
<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>
你有什麼想法嗎?非常感謝你。
您需要查看如何使用AJAX – RiggsFolly