<script language="javascript">
//表单提交按钮点击事件
function order_Click()
{
var tmpTotal="";//记录总价格变量
//累加总价
tmpTotal+=getSelRValue(document.form1.cpu);//获得选中的cpu的价格加入总价格
tmpTotal+=getSelRValue(document.form1.memory);//获得选中的内存的价格加入总价格
tmpTotal+=getSelRValue(document.form1.HardDiscs);//获得选中的硬盘的价格加入总价格
//将计算结果放入表单的隐藏控件中
document.form1.TotalPrice.value=tmpTotal;
document.form1.submit();//提交表单
}
//获得选中的单选框组的值
//参数多选框组名称
function getSelRValue(ObjRad)
{
var tTotal="";
for(var i=0;i<ObjRad.length;i++)
{
if(ObjRad[i].checked)
tTotal+=ObjRad[i].value+",";
}
return tTotal;
}
</script>
<form method="get" action="order.asp" name="form1">
<table width="1000" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="200" rowspan="5">处理器</td>
<td width="200" height="30">Intel Pentium D <input type="checkbox" name="cpu" value="1000|Intel Pentium D" /> 1000元</td>
<td width="600">详细介绍</td>
</tr>
<tr>
<td height="30">Intel Core 2 Duo <input type="checkbox" name="cpu" value="1200|Intel Core 2 Duo" /> 1200元</td>
<td width="600">详细介绍</td>
</tr>
<tr>
<td height="30">Intel Xeon DP <input type="checkbox" name="cpu" value="1400|Intel Xeon DP" /> 1400元</td>
<td width="600">详细介绍</td>
</tr>
<tr>
<td height="30">AMD Athlon X2 <input type="checkbox" name="cpu" value="900|AMD Athlon X2" /> 900元</td>
<td width="600">详细介绍</td>
</tr>
<tr>
<td height="30">AMD Phenom X4 <input type="checkbox" name="cpu" value="1300|AMD Phenom X4" /> 1300元</td>
<td width="600">详细介绍</td>
</tr>
<tr>
<td height="30"> </td>
<td> </td>
<td> </td>
</tr>
<tr>
<td rowspan="3">内存容量</td>
<td height="30">1GB <input type="checkbox" name="memory" value="200|1GB" /> 200元</td>
<td width="600">详细介绍</td>
</tr>
<tr>
<td height="30">2GB <input type="checkbox" name="memory" value="389|2GB" /> 389元</td>
<td width="600">详细介绍</td>
</tr>
<tr>
<td height="30">1GB ECC <input type="checkbox" name="memory" value="300|1GB ECC" /> 300元</td>
<td width="600">详细介绍</td>
</tr>
<tr>
<td height="30"> </td>
<td> </td>
<td> </td>
</tr>
<tr>
<td rowspan="3">硬盘容量</td>
<td height="30">160GB <input type="checkbox" name="HardDiscs" value="300|160GB" /> 300元</td>
<td width="600">详细介绍</td>
</tr>
<tr>
<td height="30">250GB <input type="checkbox" name="HardDiscs" value="423|250GB" /> 423元</td>
<td width="600">详细介绍</td>
</tr>
<tr>
<td height="30">73GB SAS <input type="checkbox" name="HardDiscs" value="299|73GB SAS" />299元</td>
<td width="600">详细介绍</td>
</tr>
<tr>
<td height="30"> </td>
<td> </td>
<td> </td>
</tr>
<tr>
<td height="30"> </td>
<td><input type="button" name="order" onClick="order_Click();" value="提交" /></td>
<td> </td>
</tr>
</table>
<input type="hidden" name="TotalPrice" >
</form>
order.asp的代码
<%
Dim i,TotalPrice,TlPrice,TlAry
TlPrice=Request.QueryString("TotalPrice")
TlAry=Split(TlPrice,",")
TotalPrice=0
Response.Write "选择的商品为<br>"
For i=0 To UBound(TlAry)
Dim tAry
tAry=Split(TlAry(i),"|")
Response.Write tAry(1)&"<br>"
TotalPrice=TotalPrice+CInt(tAry(0))
Next
Response.Write "您选择的总价格为:"&TotalPrice
%>
[[it] 本帖最后由 yms123 于 2008-12-3 13:44 编辑 [/it]]