在我的代码中,我的整个函数运行一次意味着它们没有断点。程序这样运行,当我在第一个文本框中给出值时,它会在我制作的所有文本框中给我 0。请告诉我我在做什么。我的编码是:
<html>
<head>
<title>Puchase Recipt</title>
<script type="text/javascript">
function recipt()
{
var a = Number(document.f1.amount.value);
var b = Number(document.f1.quantity.value);
var pro = a*b;
if (pro > 100)
{
var c = Number(document.f1.discount.value);
var per = Number(pro * c / 100);
var d = Number(document.f1.subtract.value);
document.f1.subtract.value = per;
}
var e = Number(document.f1.total.value);
var total = pro - per;
document.f1.total.value = total;
}
</script>
</head>
<body>
<h1>Purchase Recipt</h1>
<table border="1" bordercolor="#000099">
<form name="f1">
<tr>
<th>Amount per KG</th>
<td><input type="text" placeholder="Amount" name="amount" onChange="recipt()"/></td>
</tr>
<tr>
<th>Quntity of item</th>
<td><input type="text" placeholder="Quantity" name="quantity" onChange="recipt()"/></td>
</tr>
<tr>
<th>Discount in %</th>
<td><input type="text" placeholder="Discount" name="discount" onChange="recipt()"/></td>
</tr>
<tr>
<th>Deduct Amount</th>
<td><input type="text" placeholder="Deduct Amount" name="subtract" onChange="recipt()"/></td>
</tr>
<tr>
<th>Total Amount</th>
<td><input type="text" placeholder="Total Amount" name="total" onChange="recipt()"/></td>
</tr>
<th>Reset</th>
<td><input type="reset"/></td>
</tr>
</form>
</table>
</body>
</html>