在仔细阅读了你的问题后,帮你写了一个,不知道符合你的要求不。
我用html+js写的,关于后台的变量的接收由你自己完成。
html代码(复制到记事本后另存为以.html为后缀的文件,再到浏览器中打开看效果):
htmlhead
script language=javascript
function countAll(o){
var sum=0;
for(var i=1;i=3;i++){
eval(if(o.c + i + .checked)sum+=o.j+i+.value*o.s+i+.value;);
}
o.zong.value=sum;
}/script
/headbody
table cellspacing=0 cellpadding=0 border=1px bordercolor=#0033FF bordercolordark=#FFFF00 style=margin:1px;padding:1px;text-align:center;font:12px;word-wrap:normal;word-break:keep-all;overflow:visible; align=center
form action= method=get
tr
td width=95 rowspan=2input name=c1 type=checkbox id=c1 value=1
物品1/td
td width=319价格:
input name=j1 type=text id=j1 readonly value=20/td
/tr
tr
td数量:
input name=s1 type=text id=s1/td
/tr
tr
td rowspan=2input name=c2 type=checkbox id=c2 value=1
物品2/td
td价格:
input name=j2 type=text id=j2 readonly value=50/td
/tr
tr
td数量:
input name=s2 type=text id=s2/td
/tr
tr
td rowspan=2input name=c3 type=checkbox id=c3 value=1
物品3/td
td价格:
input name=j3 type=text id=j3 readonly value=10/td
/tr
tr
td数量:
input name=s3 type=text id=s3/td
/tr
tr
tdinput name=count type=button value=计算总价 οnclick=countAll(this.form)/tdtd总价:input name=zong type=text id=zong/td/trtrtd colspan=2input name=submit type=submit id=submit value=提交 input name=reset type=reset id=reset value=重置/td
/tr/tr/form/table
/body/html
取消
评论