a.htm
-----
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>无标题文档</title>
<script>
function f(){
  form1.submit();
}
</script>
</head><body>
<form action="a.jsp" method="post"  name="form1">
  <input type="checkbox" name="cb_1" value="8">8
<input type="checkbox" name="cb_2" value="1"> 1
<input type="checkbox" name="cb_3" value="6">6
<input type="button" name="Submit" value="按钮" onClick="f();">
</form>
</body>
</html>a.jsp
<%@ page contentType="text/html; charset=gb2312" language="java" import="java.sql.*" errorPage="" %>
<%
int t=0;
for(int i=1;i<=3;i++){
   String s=  request.getParameter("cb_"+i);
   if(s!=null){
      System.out.println(s);
      t+=Integer.parseInt(s);
   }
}
System.out.println(t);
%>
或者在客户端计算总值,传给jsp

解决方案 »

  1.   

    我想要的是ASP提交的呀,谢谢了!!!
      

  2.   

    复选框分别用checkbox1,checkbox2......命名,在提交页用如下语句,将其进行相加
    dim con_activity
    con_activity=0
    for each i in request.form
       if instr(i,"checkbox")<>0 then
          con_activity=con_activity + clng(request.form(i))
       end if
    next
      

  3.   

    改了checkbox后就不可以显示了,而且提交页它说有误,请说详细点好吗?
    谢谢了
      

  4.   

    你让"name=checkbox"而不是让"type=checkbox"
      

  5.   

    我知道,你的方法我试了.clng类型不对
    我现在解决了,谢谢你了