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
-----
<!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
解决方案 »
- 怎么实现用js或Jquery创建一个链接标签,并跳转到指定的页面?
- 请教:该怎么实现日期分割?
- EasyUI新组件-拖拽类EasyDragDrop,弹出层基类EasyLayer,遮罩类EasyMask,Popup类
- 高分求一个JS 。。不断加分,到满意
- 书上一段不了解的代码
- 请教:在客户端用javascript怎么打开系统自带的计算器和指定的记事本?
- javascript and vbscript
- 急问高手:在win98下如何进行asp测试????在线等待
- 一个关于页面分帧的问题!
- 用JS实现IFrame自适应高度,提示端口不一致的问题
- 用JS怎么能实现复选择框打上勾呢?
- 再次郁闷!!寻梦的稻草人及JS高人请进!
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
谢谢了
我现在解决了,谢谢你了