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 if(!isLoaded){ return false; }是什么意思
- 这种js表示什么意思?
- 问下标头的含义。
- checkbox问题,请各位前辈看看!
- JS代码嵌在网页中能正常显示,以<script src="ABC.js"></script>调用就不能正确显示了呢??
- 如何提交给一个无菜单和工具栏的窗体呢?
- script for.....这段代码怎样解析?
- 如下cgi包含javascript?
- 关于日期的输入的问题请教
- 通过网页的javascript 得到了当前的位置信息,但是应该怎样让这个信息替换掉我原网页中的初始地址标签
- 用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
谢谢了
我现在解决了,谢谢你了