两个界面,第一个界面用struts1.3获取值,形成list对象,第二个页面获取值.问题是,当页面传值时数字时,该条的按钮可以正常打开页面,并传值,但是当传入的是字母时,点击按钮,不能正常进入javascript代码,我想知道为什么,怎样改?
以下是代码:1.jsp
<html>
<head>
<base href="<%=basePath%>">
<title>My JSP 'MyJsp.jsp' starting page</title>
</head>
<script language="javascript">
function test(i,c){
alert("I am here !");
window.open("2.jsp?url="+i+"&zz="+c ,'_blank','');
}
</script>
<body>
<form id="form1" name="form1" method="post" action="<%=request.getContextPath() %>/test.do">
<label for="11"></label>
<input type="text" name="dd" id="dd" />
<label for="ee"></label>
<input type="text" name="ee" id="ee" />
<input type="submit" name="button" id="button" value="提交" />
</form>
<form id="form2" name="form2" method="post" action="">
<table width="200" border="1">
<%List<bean> list=(List<bean>)request.getAttribute("list");
if(list!=null&&list.size()>0){
for(int i=0;i<list.size();i++){
bean info=list.get(i);
String a=info.getDd();
String b=info.getEe();
%>
<tr>
<td width="137"><%=a%></td>
<td width="147"><%=b%></td>
<td width="127"><input type="button" name="button2" id="button2" value="按钮"
onclick="test(<%=a%>,<%=b%>)"/></td>
</tr>
<%}
}
%>
</table>
</form>
</body>
</html>2.jsp
<html>
<head>
<base href="<%=basePath%>">
<title>My JSP '2.jsp' starting page</title>
<script language="javascript">
function father(d,e){
String a=window.opener.document.form2.d1.value;
String b=window.opener.document.form2.e1.value;
document.writeln(a);
document.getElementById("1").value=a;
document.text.getElementById("2").value=b;
}
</script>
</head>
<body <%String i=request.getParameter("url");
System.out.println("---------------");
System.out.println(i);
String c=(String)request.getParameter("zz");
System.out.println(" c: "+c);
%> >
<form id="form1" name="form1" method="post" action="<%=request.getContextPath()%>">
<table width="200" border="1">
<tr>
<td width="91"><input type="hidden" id="1"><%=i %>
</td>
<td width="91"><input type="text" id="2" value="<%=c%>"/>
</td>
<td width="93"><label for="44"></label>
<%System.out.println("page2 "+i);
%>
<select name="zz" id="zz" value="null">
<option value="0" <%if ("0".equals(i)){%>selected="selected"<%}%>>--</option>
<option value="1" <%if ("1".equals(i)){%>selected="selected"<%}%>>a</option>
<option value="2" <%if ("2".equals(i)){%>selected="selected"<%}%>>b</option>
<option value="3" <%if ("3".equals(i)){%>selected="selected"<%}%>>c</option>
</select></td>
</tr>
</table>
</form>
</body>
</html>
以下是代码:1.jsp
<html>
<head>
<base href="<%=basePath%>">
<title>My JSP 'MyJsp.jsp' starting page</title>
</head>
<script language="javascript">
function test(i,c){
alert("I am here !");
window.open("2.jsp?url="+i+"&zz="+c ,'_blank','');
}
</script>
<body>
<form id="form1" name="form1" method="post" action="<%=request.getContextPath() %>/test.do">
<label for="11"></label>
<input type="text" name="dd" id="dd" />
<label for="ee"></label>
<input type="text" name="ee" id="ee" />
<input type="submit" name="button" id="button" value="提交" />
</form>
<form id="form2" name="form2" method="post" action="">
<table width="200" border="1">
<%List<bean> list=(List<bean>)request.getAttribute("list");
if(list!=null&&list.size()>0){
for(int i=0;i<list.size();i++){
bean info=list.get(i);
String a=info.getDd();
String b=info.getEe();
%>
<tr>
<td width="137"><%=a%></td>
<td width="147"><%=b%></td>
<td width="127"><input type="button" name="button2" id="button2" value="按钮"
onclick="test(<%=a%>,<%=b%>)"/></td>
</tr>
<%}
}
%>
</table>
</form>
</body>
</html>2.jsp
<html>
<head>
<base href="<%=basePath%>">
<title>My JSP '2.jsp' starting page</title>
<script language="javascript">
function father(d,e){
String a=window.opener.document.form2.d1.value;
String b=window.opener.document.form2.e1.value;
document.writeln(a);
document.getElementById("1").value=a;
document.text.getElementById("2").value=b;
}
</script>
</head>
<body <%String i=request.getParameter("url");
System.out.println("---------------");
System.out.println(i);
String c=(String)request.getParameter("zz");
System.out.println(" c: "+c);
%> >
<form id="form1" name="form1" method="post" action="<%=request.getContextPath()%>">
<table width="200" border="1">
<tr>
<td width="91"><input type="hidden" id="1"><%=i %>
</td>
<td width="91"><input type="text" id="2" value="<%=c%>"/>
</td>
<td width="93"><label for="44"></label>
<%System.out.println("page2 "+i);
%>
<select name="zz" id="zz" value="null">
<option value="0" <%if ("0".equals(i)){%>selected="selected"<%}%>>--</option>
<option value="1" <%if ("1".equals(i)){%>selected="selected"<%}%>>a</option>
<option value="2" <%if ("2".equals(i)){%>selected="selected"<%}%>>b</option>
<option value="3" <%if ("3".equals(i)){%>selected="selected"<%}%>>c</option>
</select></td>
</tr>
</table>
</form>
</body>
</html>
onclick="test('<%=a%>','<%=b%>')"/></td>