<script language="javascript">function ChgStatus(n){
switch(n)
{
case 1:
for(i=1;i<5;i++)
{
eval("opcontent"+i+".checked=false")
eval("opcontent"+i+".disabled=true")
}
for(i=5;i<9;i++)
{
eval("opcontent"+i+".disabled=false")
}
break;case 2:
for(i=1;i<5;i++)
{
eval("opcontent"+i+".disabled=false")
}
for(i=5;i<9;i++)
{
eval("opcontent"+i+".checked=false")
eval("opcontent"+i+".disabled=true")
}
break;case 3:
for(i=1;i<9;i++)
{
eval("opcontent"+i+".checked=false")
eval("opcontent"+i+".disabled=true")
}break;
}
}</script>
<input type="radio" class="radio" size="10" name="cfcf" id="cfyou" onclick="ChgStatus(1);"></input>
<input type="checkbox" class="checkbox" name="opcontent1" value="1" id="opcontent">
<input type="checkbox" class="checkbox" name="opcontent2" value="2" id="opcontent">
<input type="checkbox" class="checkbox" name="opcontent3" value="3" id="opcontent">
<input type="checkbox" class="checkbox" name="opcontent4" value="4" id="opcontent"><input type="radio" class="radio" size="10" name="cfcf" id="cfwu" onclick="ChgStatus(2);"></input><input type="checkbox" class="checkbox" name="opcontent5" value="5" id="opcontent">
<input type="checkbox" class="checkbox" name="opcontent6" value="6" id="opcontent">
<input type="checkbox" class="checkbox" name="opcontent7" value="7" id="opcontent">
<input type="checkbox" class="checkbox" name="opcontent8" value="8" id="opcontent"><input type="radio" class="radio" size="10" name="cfcf" id="cfwu" onclick="ChgStatus(3);"></input>

解决方案 »

  1.   

    <script language="javascript">/* 使用方法
    ** 第一个参数为要disabled的checkbox的name,如果为多个用,隔开
    ** 第二个参数为要enabled的checkbox的name,如果多个用,隔开
    */
    function ChgStatus(el){
    elArr = el.split(",");
    for(i=0;i<elArr.length;i++)
    {
    var op = document.getElementsByName(elArr[i]);
    for(j=0;j<op.length;j++)
    {
    op[j].checked  = false;
    op[j].disabled = true;
    }
    }
    if(arguments.length >1 )
    {
    elArr = arguments[1].split(",");
    for(i=0;i<elArr.length;i++)
    {
    var op = document.getElementsByName(elArr[i]);
    for(j=0;j<op.length;j++)
    {
    op[j].checked  = false;
    op[j].disabled = false;
    }
    }
    }
    }</script>
        <input type="radio" class="radio" size="10" name="cfcf" id="cfyou" onclick="ChgStatus('op1','op2');"></input>
        <input type="checkbox" class="checkbox" name="op1" value="1">
        <input type="checkbox" class="checkbox" name="op1" value="2">
        <input type="checkbox" class="checkbox" name="op1" value="3">
        <input type="checkbox" class="checkbox" name="op1" value="4">
        
        <input type="radio" class="radio" size="10" name="cfcf" id="cfwu" onclick="ChgStatus('op2','op1');"></input>
        
        
        <input type="checkbox" class="checkbox" name="op2" value="5">
        <input type="checkbox" class="checkbox" name="op2" value="6">
        <input type="checkbox" class="checkbox" name="op2" value="7">
        <input type="checkbox" class="checkbox" name="op2" value="8">
        
        
        <input type="radio" class="radio" size="10" name="cfcf" id="cfwu" onclick="ChgStatus('op1,op2');"></input>
      

  2.   

    to net_lover(孟子E章) 
    循环加选择,执行应该更耗资源吧如果把所有的checkbox改称统一的名字,怎样识别呢?