<html>
<head>
<title>累加计算</title>
<script language="javascript">
function Total_Click()
{
var BjTotal=0;//报价
var CjTotal=0;//成交价
for(var i=0;i<this.Item.length;i++)
{
if(this.Item[i].checked)
{
var tAry=this.Item[i].value.split('|');
BjTotal+=parseInt(tAry[0]);
CjTotal+=parseInt(tAry[1]);
}
}
this.Result.value="报价为:"+BjTotal+" 成交价:"+CjTotal;
}
function selAll_Click()
{
for(var i=0;i<this.Item.length;i++)
{
this.Item[i].checked=this.selAll.checked;
}
}
</script>
</head>
<body>
<table>
<tr>
<td>名称</td><td>报价</td><td>成交价</td><td>复选框</td>
</tr>
<tr>
<td>1</td><td>1000</td><td>800</td><td><input type="checkbox" name="Item" value="1000|800" ></td>
</tr>
<tr>
<td>2</td><td>1100</td><td>1000</td><td><input type="checkbox" name="Item" value="1100|1000" ></td>
</tr>
<tr>
<td>3</td><td>1500</td><td>1200</td><td><input type="checkbox" name="Item" value="1500|1200" ></td>
</tr>
<tr>
<td>4</td><td>900</td><td>600</td><td><input type="checkbox" name="Item" value="900|600" ></td>
</tr>
</table>
<input type="button" name="Total" onClick="Total_Click();" value="累计">
<input type="text" name="Result" value="">计算结果<br>
<input type="checkbox" name="selAll" onClick="selAll_Click();">全选
</body>
</html>