我正在尝试计算我的 html 表单值。
我已经尝试了以下 javascript 计算,但它没有在我的总字段('total1')中计算一个值。javascript可能有问题还是我没有正确引用表单?
<form action="" method="get" id="quote">
<table width="532" border="1" cellspacing="1" cellpadding="0.5">
<tr>
<th width="109" scope="col"><div align="center">Date</div></th>
<th width="158" scope="col"><div align="center">Half day</div></th>
<th width="112"><div align="center">Full day</div></th>
<th width="134"><div align="center">Total for the day</div></th>
</tr>
<tr>
<td><div align="center">
<input name="date1" type="text" size="15" />
</div></td>
<td><div align="center">
<input name="halfday1" type="text" size="15" maxlength="10" />
</div></td>
<td><div align="center">
<input name="fullday1" type="text" size="15" />
</div></td>
<td><div align="center">
<input name="total1" type="text" size="15" />
</div></td>
</tr>
<tr>
<td><div align="center">
<input name="date2" type="text" size="15" />
</div></td>
<td><div align="center">
<input name="halfday2" type="text" size="15" />
</div></td>
<td><div align="center">
<input name="fullday2" type="text" size="15" />
</div></td>
<td><div align="center">
<input name="total2" type="text" size="15" />
</div></td>
</tr>
<tr>
<td><div align="center">
<input name="date3" type="text" size="15" />
</div></td>
<td><div align="center">
<input name="halfday3" type="text" size="15" />
</div></td>
<td><div align="center">
<input name="fullday3" type="text" size="15" />
</div></td>
<td><div align="center">
<input name="total3" type="text" size="15" />
</div></td>
</tr>
<tr>
<td><div align="center"></div></td>
<td><div align="center"></div></td>
<td><div align="center"></div></td>
<td><div align="center"></div></td>
</tr>
</table>
</form>
function doTotal(quote) {
var a = (form.halfday1.value != '') ? eval(form.halfday1.value) : 0;
var b = (form.fullday1.value != '') ? eval(form.fullday1.value) : 0;
form.total1.value = a + b + c + d + e;
}