小小的问题,搞定给分

thefishwilldie 2003-10-09 10:14:07
我在一个页面需要动态生成一个checkbox(不知道有多少项,先以3项为例),
在另外的新打开的页面要得到它的值该怎么办?
程序如下:page1.jsp
<%@ page contentType="text/html; charset=gb2312" language="java" import="java.sql.*" errorPage="" %>
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
</head>

<body>
<form name="form1" method="post" action="temp2.jsp">
<input type="checkbox" name="checkbox" value="1">
<input type="checkbox" name="checkbox" value="2">
<input type="checkbox" name="checkbox" value="3">
<input type="submit" name="Submit" value="Submit" onClick="saveDatum();">


</form>


</body>
<script language="javascript">

function saveDatum(){
window.open('temp2.jsp?','','');
}
</script>
</html>





temp2.jsp:
<%@ page contentType="text/html; charset=gb2312" language="java" import="java.sql.*" errorPage="" %>
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
</head>

<body>
<%
String[] str=request.getParameterValues("checkbox");
for(int i=0;i<str.length;i++){
out.print(str[i]+"<br>");
}
%>
</body>
</html>
这样做老报错不知道该怎么解决?!
...全文
44 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
thefishwilldie 2003-10-09
  • 打赏
  • 举报
回复
谢谢szpqq(Gavin)问题解决了。
szpqq 2003-10-09
  • 打赏
  • 举报
回复
在page1.jsp中的form中加上target='_blank',去掉js,即
<%@ page contentType="text/html; charset=gb2312" language="java" import="java.sql.*" errorPage="" %>
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
</head>

<body>
<form name="form1" method="post" action="temp2.jsp" target='_blank'>
<input type="checkbox" name="checkbox" value="1">
<input type="checkbox" name="checkbox" value="2">
<input type="checkbox" name="checkbox" value="3">
<input type="submit" name="Submit" value="Submit">


</form>


</body>
thefishwilldie 2003-10-09
  • 打赏
  • 举报
回复
我想在本页新开一个窗口,然后传值给新开的窗口啊!
unsalted 2003-10-09
  • 打赏
  • 举报
回复
同意楼上的,把js去掉就可以了。
realzealy 2003-10-09
  • 打赏
  • 举报
回复
你什么意思啊,已经用了post方法向服务器提交了表单,还用js编一个saveDatum()干吗啊
不明白你的saveDatum()有什么用,你把这个去掉了直接用post传参数不就OK了吗

81,090

社区成员

发帖
与我相关
我的任务
社区描述
Java Web 开发
社区管理员
  • Web 开发社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧