首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > JAVA > Java Web开发 >

如果把checkbox选项的内容传到后台数据库解决办法

2012-01-20 
如果把checkbox选项的内容传到后台数据库RT见答案马上结帖菜鸟希望能说详细点最好有关键代码谢谢了[解决办

如果把checkbox选项的内容传到后台数据库
RT   见答案马上结帖菜鸟   希望能说详细点   最好有关键代码   谢谢了

[解决办法]
说详细点,什么数据库,什么问题
想用什么技术
[解决办法]
页面:
<input type= "checkbox " name= "chk " value= "1 " /> 1
<input type= "checkbox " name= "chk " value= "2 " /> 2
<input type= "checkbox " name= "chk " value= "3 " /> 3
服务器:
String[] values = request.getParameterValues( "chk ");

结果:
values==null
1个也没选中。
values 包含值 1
第一个被选中



[解决办法]

//test.jsp
<form name="form1" action="test/b.jsp" method="post">
<input type="hidden" name="submitted" value="true">
<tr>
<td><input type="checkbox" name="test" value="1">1</td>
<td><input type="checkbox" name="test" value="2">2</td>
<td><input type="checkbox" name="test" value="3">3</td>
</tr>
<tr>
<td colspan=3><input type="submit" name="submit" value="sub"></td>
</tr>

</form>


//b.jsp
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<body> 
<c:forEach items="<%=request.getParameterValues("test") %>" var="s">
${s }
</c:forEach>
[解决办法]
String [] selects = request.getParameterValues();

热点排行