日期:2014-05-16  浏览次数:20395 次

求 radio + text 的显示与隐藏的问题
怎样用   java   完成以下内容??

有若干   radio+text   组(每组的内容相同,具体几组根据需要决定),
当单击   组1   的   radio1   时,显示   组1   的   text框   并验证是否为空;
当单击   组2   的   radio1   时,显示   组2   的   text框   并验证是否为空;
依此类推,


现在显示已完成,但我现在的情况是:
当单击   组1   的   radio1   时,不但对   组1   的   text框   进行验证,对   组2的   text框  
也进行验证(组2   的   text框   并不显示出来   ),我要求只对   组1   的   text框
进行验证

------解决方案--------------------
look
---------------------------
<script type= "text/javascript ">
function check(frm){
var rd = document.getElementsByName( "r1 ");
for(var i=0;i <rd.length;i++){
if(rd[i].checked){
var obj = document.getElementById( "t " + rd[i].value);
if(obj.value== " "){
alert( "请输入值! ");
obj.focus();
return false;
}
}
}
}

</script>
<form onsubmit= "return check(); " name= "form1 ">
<input type= "radio " name= "r1 " value= "1 "> <input type= "text " name= "t1 " id= "t1 ">
<input type= "radio " name= "r1 " value= "2 "> <input type= "text " name= "t2 " id= "t2 ">
<input type= "radio " name= "r1 " value= "3 "> <input type= "text " name= "t3 " id= "t3 ">
<input type= "radio " name= "r1 " value= "4 "> <input type= "text " name= "t4 " id= "t4 ">
<input type= "submit " value= "submit ">
</form>