<input type=checkbox onclick="aa()" name=a>
<input type=checkbox name=a>
<input type=checkbox name=a>
<input type=checkbox name=a>
<script>
function aa()
{
l=document.getElementsByName("a")
for(i=0;i<l.length;i++) l[i].checked=event.srcElement.checked
}
</script>

解决方案 »

  1.   

    <input type=checkbox name=c>
    <input type=checkbox name=c> 
    <input type=checkbox name=c> 
    <input type=checkbox name=c> 
    <input type=checkbox name=c> 
    <input type=checkbox name=c> 
    <input type=checkbox name=c> 
    <input type=checkbox name=c> 
    <input type=checkbox name=c> 
    <script> 
    document.onclick=check;
    function check(){
    var num=0;
    for (i=0;i<document.all.c.length;i++){
    if(document.all.c[i].checked){
    num++
    if (num>1){//可以设置个数
    event.returnValue=false;
    }
    }
    }
    }
    </script>
      

  2.   

    <form name=form1>
    <input type=checkbox name=mm onclick=aa(this)><br>
    <input type=checkbox name=mm><br>
    <input type=checkbox name=mm><br>
    <input type=checkbox name=mm><br>
    </form><script language="JavaScript">
    <!--
    function aa(e)
    {
        var a = document.form1.elements;
        for (var i=0; i<a.length; i++)
          if(a[i].type=="checkbox" && a[i].name=="mm")
            a[i].disabled = e.checked;
        e.disabled = false;
    }
    //-->
    </script>
      

  3.   

    <input type=checkbox onclick="aa(this)">
    <input type=checkbox onclick="aa(this)"><input type=checkbox onclick="aa(this)"><input type=checkbox onclick="aa(this)">
    <input type=checkbox onclick="aa(this)">
    <input type=checkbox onclick="aa(this)">
    <input type=checkbox onclick="aa(this)">
    <script>
    function aa(obj){
    var s = document.getElementsByTagName("input");
    for(var i =0 ;i<s.length;i++)
    {
    if(s[i].type=="checkbox")
    if(s[i]!=obj)
    s[i].disabled = obj.checked?true:false;
    }
    }
    </script>