日期:2014-05-18  浏览次数:20791 次

六个单选,每个单选后有三个复选框,选择其中一个单选后只能选对应的三个复选,其它的复选不让选
六个单选,每个单选后有三个复选框,选择其中一个单选后只能选对应的三个复选,其它的复选不让选,并且如果其它的单选按钮还让选,并且如果重新选择了其它的单选,则能选择的复选框也相应的改变。

------解决方案--------------------
<html>

<head>
<meta http-equiv= "Content-Type " content= "text/html; charset=gb2312 ">
<title> 新建网页 1 </title>
<script>

function radioClick(radio){

if(radio== "radio1 "){

var checks=document.getElementsByName( "checkbox1 ");
for(i=0;i <checks.length;i++){

checks[i].disabled=null;
}
var checks=document.getElementsByName( "checkbox2 ");
for(i=0;i <checks.length;i++){

checks[i].disabled=true;
}
}
else if(radio== "radio2 "){
alert( "ff ");
var checks=document.getElementsByName( "checkbox2 ");
for(i=0;i <checks.length;i++){

checks[i].disabled=null;
}
var checks=document.getElementsByName( "checkbox1 ");
for(i=0;i <checks.length;i++){

checks[i].disabled=true;
}
}

}
</script>
</head>

<body>
<input type= "radio " id= "rd " name= "rd " value= "radio1 " onclick= "radioClick(this.value); "> radio1
<input type= "checkbox " name= "checkbox1 " value= "checkbox1-1 "> checkbox1-1
<input type= "checkbox " name= "checkbox1 " value= "checkbox1-2 "> checkbox1-2
<input type= "checkbox " name= "checkbox1 " value= "checkbox1-3 "> checkbox1-3
<input type= "radio " id= "rd " name= "rd " value= "radio2 " onclick= "radioClick(this.value); "> radio2
<input type= "checkbox " name= "checkbox2 " value= "checkbox2-1 "> checkbox2-1
<input type= "checkbox " name= "checkbox2 " value= "checkbox2-2 "> checkbox2-2
<input type= "checkbox " name= "checkbox2 " value= "checkbox2-3 "> checkbox2-3
</body>

</html>