0
<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>

我最近测试了发布在 net 上的脚本,它可以工作,但我想我做错了什么:'( 我严重卡在其中,因为诸如 amount1、totalamount 和 balance 之类的动态变量导致未定义索引 amount1 等错误

请弄清楚:(

php很简单>>

<?php
echo $_POST['unit1'];
echo $_POST['rate1'];
echo $_POST['amount1'];
?>
4

1 回答 1

2

禁用时不会提交表单元素(禁用amount1,totalamount和balance)

改用只读属性

于 2012-09-09T14:42:28.440 回答