大家看我的代码:
为什么只能接收到第一个值而不是所有的值呢?
//updade_cou.jsp
<table width="563" height="23" border="1" cellpadding="0" cellspacing="0" bordercolor="#99FFFF" align="center">
<form id="form2" name="form2" method="post" action="del_add_cou.jsp">
<tr align="center">
<th width="84" height="17">课程号</th>
<th width="358">课 程</th>
<th width="99"><input type="image" name="imageField2" src="../../image/apply.png" /></th>
</tr>
<%
while(rsCourse.next())
{
%>
<tr align="center">
<td width="84" height="17"><%=rsCourse.getString("Cno")%></td>
<td width="358"><%=rsCourse.getString("Cname")%></td>
<td width="99">
<input name="sno" type="hidden" id="sno" value="<%=strId%>" />
<input name="Cno" type="hidden" id="Cno" value="<%=rsCourse.getString("Cno")%>"/>
<%
if(rsCno.next())
{
i++;
%>
<label>
<input name="check" type="checkbox" id="check" checked="checked" value="<%=i%>"/>
</label>
<%
}
else
{
j++;
//out.print(j);
%>
<label>
<input name="uncheck" type="checkbox" id="uncheck" />
</label>
<%
}
%>
</td>
</tr>
</form>
<%
}
out.print(i);
%>
<br>
<%
out.print(j);
%>
</table>//del_add_cou.jsp<%
chStr trim = new chStr();String strSno=trim.chStr(request.getParameter("sno"));
String strCno=trim.chStr(request.getParameter("Cno"));
//String strUncheck[] = {""};
//String strChecked[] = {""};
String[] strUncheck = request.getParameterValues("uncheck");
String[] strChecked = request.getParameterValues("check");
for(int i=0;strUncheck !=null && i<strUncheck.length; i++)
{
out.print(strUncheck[i]);
}
for(int i=0;strChecked !=null && i<strChecked.length; i++)
{
out.print(strChecked[i]);
}
%>
为什么只能接收到第一个值而不是所有的值呢?
//updade_cou.jsp
<table width="563" height="23" border="1" cellpadding="0" cellspacing="0" bordercolor="#99FFFF" align="center">
<form id="form2" name="form2" method="post" action="del_add_cou.jsp">
<tr align="center">
<th width="84" height="17">课程号</th>
<th width="358">课 程</th>
<th width="99"><input type="image" name="imageField2" src="../../image/apply.png" /></th>
</tr>
<%
while(rsCourse.next())
{
%>
<tr align="center">
<td width="84" height="17"><%=rsCourse.getString("Cno")%></td>
<td width="358"><%=rsCourse.getString("Cname")%></td>
<td width="99">
<input name="sno" type="hidden" id="sno" value="<%=strId%>" />
<input name="Cno" type="hidden" id="Cno" value="<%=rsCourse.getString("Cno")%>"/>
<%
if(rsCno.next())
{
i++;
%>
<label>
<input name="check" type="checkbox" id="check" checked="checked" value="<%=i%>"/>
</label>
<%
}
else
{
j++;
//out.print(j);
%>
<label>
<input name="uncheck" type="checkbox" id="uncheck" />
</label>
<%
}
%>
</td>
</tr>
</form>
<%
}
out.print(i);
%>
<br>
<%
out.print(j);
%>
</table>//del_add_cou.jsp<%
chStr trim = new chStr();String strSno=trim.chStr(request.getParameter("sno"));
String strCno=trim.chStr(request.getParameter("Cno"));
//String strUncheck[] = {""};
//String strChecked[] = {""};
String[] strUncheck = request.getParameterValues("uncheck");
String[] strChecked = request.getParameterValues("check");
for(int i=0;strUncheck !=null && i<strUncheck.length; i++)
{
out.print(strUncheck[i]);
}
for(int i=0;strChecked !=null && i<strChecked.length; i++)
{
out.print(strChecked[i]);
}
%>
楼主【tidelgl】截止到2008-06-23 22:42:26的历史汇总数据(不包括此帖):
发帖数:0 发帖分:0
结贴数:0 结贴分:0
未结数:0 未结分:0
结贴率:-------------------结分率:-------------------
如何结贴请参考这里:http://topic.csdn.net/u/20080501/09/ef7ba1b3-6466-49f6-9d92-36fe6d471dd1.html
<input name="Cno" type="hidden" id="Cno" value="<%=rsCourse.getString("Cno")%>"/>
红色去掉,看下Cno有没有值
String[] strUncheck = request.getParameterValues("uncheck").split(",");//分割下字符
String[] strChecked = request.getParameterValues("check").split(",");//分割下字符
前一部分真实是这样的:
//update_cou.jsp
<table width="563" height="23" border="1" cellpadding="0" cellspacing="0" bordercolor="#99FFFF" align="center">
<form id="form2" name="form2" method="post" action="del_add_cou.jsp">
<tr align="center">
<th width="84" height="17">课程号</th>
<th width="358">课 程</th>
<th width="99"><input type="image" name="imageField2" src="../../image/apply.png" /></th>
</tr>
<%
while(rsCourse.next())
{
%>
<tr align="center">
<td width="84" height="17"><%=rsCourse.getString("Cno")%></td>
<td width="358"><%=rsCourse.getString("Cname")%></td>
<td width="99">
<input name="sno" type="hidden" id="sno" value="<%=strId%>" />
<input name="Cno" type="hidden" id="Cno" value="<%=rsCourse.getString("Cno")%>"/>
<%
if(rsCno.next())
{
i++;
%>
<label>
<input name="check" type="checkbox" id="check" checked="checked" value="<%=rsCourse.getString("Cno")%>"/>
</label>
<%
}
else
{
j++;
//out.print(rsCourse.getString("Cno"));
%>
<label>
<input name="uncheck" type="checkbox" id="uncheck" value="<%=rsCourse.getString("Cno")%>"/>
</label>
<%
}
%>
</td>
</tr>
</form>
<%
}
out.print(i);
%>
<br>
<%
out.print(j);
%>
</table>
找不到符号
符号: 方法 split(java.lang.String)
位置: 类 java.lang.String[]
String[] strUncheck = request.getParameterValues("uncheck").split(",");
^
split(" ");//直接这样看看
就是只有第一个元素的值..
//del_add_cou.jsp<%
chStr trim = new chStr();String strSno=trim.chStr(request.getParameter("sno"));
String strCno=trim.chStr(request.getParameter("Cno"));
//String strUncheck[] = {""};
//String strChecked[] = {""};
String[] strUncheck = request.getParameterValues("uncheck");
String[] strChecked = request.getParameterValues("check");
for(int i=0;strUncheck !=null && i<strUncheck.length; i++)
{
out.print(strUncheck[i]);
}
for(int i=0;strChecked !=null && i<strChecked.length; i++)
{
out.print(strChecked[i]);
}
%>
直接得到的就是数组了