Spring mvc中如何获得jsp里面复选按钮和单选按钮的值
Spring mvc中怎么获得jsp里面复选按钮和单选按钮的值
name都是“type”,在controller里面怎么知道哪个被选中了。。
还有这种单选按钮的怎么获得
谢谢
------解决方案--------------------
如果直接不能获取的话,可以这样 给单选按钮组一个事件,增加一个隐藏域,每次选择时吧选择的值给隐藏域,然后后台直接获取隐藏域的值就行了....
------解决方案--------------------
Spring mvc 没用过,按name来取值,接收到的值是选中的元素.request.getParameters();
------解决方案--------------------
用js可以实现吧
var tdlist = $("table").find("tr").find("td");
var chkboxstr = "";
$.each(tdlist,function(idx,item){
var chkbox = $(this).find("input[type=checkbox]");
if($(chkbox).attr("checked")){
chkboxstr += $(chkbox).val() + ","
}
});
alert(chkboxstr.substring(0, chkboxstr.length-1));
------解决方案--------------------
从request 中取数据。。
<td align="center"><input type="checkbox" name="type"
value="go_straight" id="go_straight2">直达1</td>
<td align="center"><input type="checkbox" name="type"
value="back_straight" id="back_straight2">直达2</td>
<td align="center"><input type="checkbox" name="type"
value="go_addon" id="go_addon2">附加1</td>
<td align="center"><input type="checkbox" name="type"
value="back_addon" id="back_addon2">附加2</td>
<td align="center"><input type="checkbox" name="type"
value="go_spa" id="go_spa2">附加3</td>
<td colspan="2" align="center"><input type="checkbox"
name="type" value="back_spa" id="back_spa2">附加4</td>
name都是“type”,在controller里面怎么知道哪个被选中了。。
还有这种单选按钮的怎么获得
<td align="center">
<input type="radio" value="go_straight" name="type" id="go_straight" checked="checked" />直达1
<input type="radio" value="back_straight" name="type" id="back_straight" />直达2</td>
<td align="center">
<input type="radio" value="go_addon" id="go_addon" name="type" />附加1
<input type="radio" value="back_addon" id="back_addon" name="type" />附加2
</td>
<td align="center" colspan="2">
<input type="radio" value="go_spa" id="go_spa" name="type" /附加3
<input type="radio" value="back_spa" id="back_spa" name="type" />附加4</td>
谢谢
------解决方案--------------------
如果直接不能获取的话,可以这样 给单选按钮组一个事件,增加一个隐藏域,每次选择时吧选择的值给隐藏域,然后后台直接获取隐藏域的值就行了....
------解决方案--------------------
Spring mvc 没用过,按name来取值,接收到的值是选中的元素.request.getParameters();
------解决方案--------------------
用js可以实现吧
var tdlist = $("table").find("tr").find("td");
var chkboxstr = "";
$.each(tdlist,function(idx,item){
var chkbox = $(this).find("input[type=checkbox]");
if($(chkbox).attr("checked")){
chkboxstr += $(chkbox).val() + ","
}
});
alert(chkboxstr.substring(0, chkboxstr.length-1));
------解决方案--------------------
从request 中取数据。。