各位大哥:
小弟有一问题等待你们救命啊,我在页面上循环多组radio框,这该怎么做啊,现在的情况是循环出来的记录,比如10条,每条上有2个选项,是和否,这10组radio框只能选一组。怎样才能让每组都能选择呢?谢谢!不胜感激,就这点分都给了!
小弟有一问题等待你们救命啊,我在页面上循环多组radio框,这该怎么做啊,现在的情况是循环出来的记录,比如10条,每条上有2个选项,是和否,这10组radio框只能选一组。怎样才能让每组都能选择呢?谢谢!不胜感激,就这点分都给了!
有几个要选择的就作几个组吧
这样每个组都能选择了
checkbox比如我有10条记录,5条打勾,那么actionform获取的数组数是5,而没有打勾的那五条我获取不到啊。
不知道你怎么循环的(js,还是struts标签,还是jstl等等)
咋回答?
例如:
<input type="radio" name="r1"/>
<input type="radio" name="r1"/>
<br>
<input type="radio" name="r2"/>
<input type="radio" name="r2"/>
<br>
<input type="radio" name="r3"/>
<input type="radio" name="r3"/>
<html>
<head>
<title>radio</title>
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">
<script type="text/javascript">
function check(){
var radios=document.getElementsByTagName("input");
for(var i=0;i<radios.length;i++){
if(radios[i].type=="radio"){
if(radios[i].checked){
alert(radios[i].name+"\t"+radios[i].value);
}
}
}
}
</script>
</head> <body>
<input type="radio" name="radio1" value="true">是
<input type="radio" name="radio1" value="false">否
<br>
<input type="radio" name="radio2" value="true">是
<input type="radio" name="radio2" value="false">否
<br>
<input type="radio" name="radio3" value="true">是
<input type="radio" name="radio3" value="false">否
<br>
<input type="radio" name="radio4" value="true">是
<input type="radio" name="radio4" value="false">否
<br>
<input type="radio" name="radio5" value="true">是
<input type="radio" name="radio5" value="false">否
<br>
<input type="button" value="submit" onclick="check();">
</body>
</html>