在Servlet端获取html页面选中的checkbox值,request获取页面checkbox(复选框)值

时间:2020-03-20 16:54:44   收藏:0   阅读:193

html端代码:

适用人群:
<input type="checkbox" name="crowd" value="幼儿">幼儿
<input type="checkbox" name="crowd" value="青少年">青少年
<input type="checkbox" name="crowd" value="中年">中年
<input type="checkbox" name="crowd" value="老年">老年<br>

servlet代码:

//request获取页面checkbox(复选框)值
String[] crowd=request.getParameterValues("crowd");
String a="";
for(int i=0;i<crowd.length;i++)
a+=crowd[i]+",";
out.print("适用人群:"+a+"<br>");

评论(0
© 2014 mamicode.com 版权所有 京ICP备13008772号-2  联系我们:gaon5@hotmail.com
迷上了代码!