自定义多个相同文本输入框值的计算问题?
如下代码所示为一个自定义的多个文本输入框:
<table width="734" border="0" align="center" cellpadding="0" cellspacing="1">
<tr>
<td width="100" height="40" rowspan="2" align="center" bgcolor="#FFFFFF">房 费</td>
<td height="25" bgcolor="#FFFFFF"><script language="javascript">
function setid()
{
str='<br>';
if(!window.form1.hotelnum.value)
window.form1.upcount.value=1;
for(i=1;i<=window.form1.hotelnum.value;i++)
str+='宾馆名称'+'<input type="text" class="input3" name="hotelname'+'" size="16">'+' 报价'+'<input type="text" class="input3" name="hotelprice'+'" size="10">'+' 天数'+'<input type="text" class="input3" name="hotelday'+'" size="16">'+' 成本'+'<input type="text" class="input3" name="hotelprice_old'+'" size="16"><br>';
window.upid.innerHTML=str+'<br>';
}
</script>
需要入住的宾馆个数
<input name="hotelnum" type="text" class="input3" value="1" size="10">
<input type="button" name="Button" class="input3" onClick="setid();" value="设定">
<a href="hotel.htm" target="_blank"><font color="#FF3366">点击查看宾馆详细信息</font></a> </td>
</tr>
<tr>
<td align="left" id="upid" bgcolor="#FFFFFF"> 宾馆名称
<input name="hotelname" type="text" class="input3"size="16" > 报价
<input name="hotelprice" type="text" class="input3" size="10" >
天数
<input name="hotelday" type="text" class="input3" size="10" > 成本
<input name="hotelprice_old" type="text" class="input3" size="10">
<input name="ab" type="text" class="input3" id="ab"></td>
</tr>
</table>
如现在有5行这样的文本输入框,我想要统计:
报价*天数 的总和,就相当于:报价1*天数1+报价2*天数2+...+报价n*天数n
成本*天数 的总和,就相当于:成本1*天数1+成本2*天数2+...+成本n*天数n
求高手帮忙解决~~~~~~急用啊~下午老板就要检查了!