<form action="testing.php" method="POST" id="addreciept" name="addreciept">
Unit<input name="unit1" type="text" id="unit1" size="17" onkeyup="calc()" value="0"/>
Rate<input name="rate1" type="text" id="rate1" size="17" value="0" onkeyup="calc()" />
Amount<input name="amount1" type="text" id="amount1" size="17" disabled="true" />
Total Amount: <input type="text" name="totalamount" id="totalamount" disabled="true" value="">
Amount Paid: <input type="text" name="amount_paid" id="amount_paid" onkeyup="calc_balance()" />
Balance: <input type="text" name="balance" id="balance" disabled="true" value="0">
<center>
<input type="submit" value="Save " class="button" >
</center>
</form>
<script>
function calc()
{
unit=document.getElementById('unit1').value;
rate=document.getElementById('rate1').value;
amount=unit*rate;
document.getElementById('amount1').value=amount;
total_amount=document.getElementById('amount1').value;
document.getElementById('totalamount').value=total_amount;
}
function calc_balance()
{
tota_amount=document.getElementById('totalamount').value;
paid_amount=document.getElementById('amount_paid').value;
document.getElementById('balance').value=tota_amount-paid_amount;
}
</script>
我最近测试了网络上发布的脚本,它可以工作,但我想我做错了什么:'(我严重陷入其中,因为动态变量如 amount1、totalamount & balance 导致未定义的索引 amount1 等错误
请弄清楚:(
PHP只是简单的>>
<?php
echo $_POST['unit1'];
echo $_POST['rate1'];
echo $_POST['amount1'];
?>
表单元素在禁用时不会提交(金额1,总金额和余额被禁用(
改用只读属性