可以用超连接后跟参数的方式传递参数
?后是参数,如果有多个参数,用&分隔。
传递的参数被放在 request里。在另一个页面用request.getParameter()获得
pass.jsp
===================================================
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<%@ page contentType="text/html; charset=gb2312"%><html>
<head>
</head>
<script>
function pass(){
window.location="recevie.jsp?textValue="+document.all.text1.value;
}
</script>
<body>
<input type="text" name="text1" value="">
<a href="#" onclick="pass()">传递文本框中的值到下一个页面
</a>
</body>
</html>recevie.jsp
===============================================
<%@ page contentType="text/html; charset=gb2312"%>
从上个页面传过来的值为:<input type="text" value="<%=request.getParameter("textValue")%>">
?后是参数,如果有多个参数,用&分隔。
传递的参数被放在 request里。在另一个页面用request.getParameter()获得
pass.jsp
===================================================
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<%@ page contentType="text/html; charset=gb2312"%><html>
<head>
</head>
<script>
function pass(){
window.location="recevie.jsp?textValue="+document.all.text1.value;
}
</script>
<body>
<input type="text" name="text1" value="">
<a href="#" onclick="pass()">传递文本框中的值到下一个页面
</a>
</body>
</html>recevie.jsp
===============================================
<%@ page contentType="text/html; charset=gb2312"%>
从上个页面传过来的值为:<input type="text" value="<%=request.getParameter("textValue")%>">
也就是说n行的文本框的name都相同,怎么写?
url.jsp?a=xx&b=xx&c=............
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<%@ page contentType="text/html; charset=gb2312"%><html>
<head>
</head>
<script>
function pass(){
//拼 传递参数字符串
var parameters="";
for(i=0;i<document.all.text1.length;i++){
parameters+="text"+i+"="+document.all.text1[i].value+"&";
}
//去掉末尾的"&"
parameters=parameters.substring(0,parameters.length-1);
//定位到receive.jsp
window.location="recevie.jsp?"+parameters;
}
</script>
<body>
<%
for(int i=0;i<10;i++){
%>
文本框<%=i%><input type="text" name="text1" value=""><br><br>
<%
}
%>
<a href="#" onclick="pass()">传递文本框中0-9的值到下一个页面</a><br>
</body>
</html>
receive.jsp====================================================
<%@ page contentType="text/html; charset=gb2312"%>从上个页面传过来的值为:<br><%
for(int i=0;i<10;i++){
String text=request.getParameter("text"+i);
%>
文本框<%=i%><input type="text" name="text1" value="<%=text%>"><br><br>
<%
}
%>
服务器用request.getParameterValues(java.lang.String name)得到一个String[]
这样是可以传递将页面上所有的文本框的值传过去,但我要是在循环里的超连接
(也就是用循环输出的table)每行都有一个超连接,此超连接不但要传递该行文本框里的值,
还要传递该行内部分<td><%=fvo.getUserId()%></td>里的值,该怎样写?
(我发)如果我在传递文本框里的值的同时需要同时传递其他参数(用超连接)
这样可以识别<%=fvo.getUserId()%>这样的标识,用资源名?参数的形式
这样同时也可得到文本框里的输入值