jsp获取radio的值
我现在在jsp中这样一个radio: <input type="radio" name="keyMan" value=""/>是 <input type="radio" name="keyMan" value=""/>否 我在后台返回一个“是”,请问我怎么在页面上显示选择在是上?
最佳答案
首先你的代码是有问题的,你选“是”还是“否”的标准时你的value值,然而你的value值现在都是空字符串。你这样写
在后台不要返回是,返回数字1或者0赋值给变量i。
<%int i = request.getParameter("value");%>
<input type="radio" name="keyMan" value="1" <%if(i==1){out.print("select");} %>/>是
<input type="radio" name="keyMan" value="0" <%if(i==1){out.print("select");} %>/>否
这样你就可以动态的控制radio的默认选择了。
本文介绍如何在JSP页面中设置Radio按钮的默认选中状态,通过从后台获取值并根据该值动态控制Radio按钮的选择状态。
704

被折叠的 条评论
为什么被折叠?



