<script language=javascript>
function selall_inform(chk,selected)
{
    if (selected==null || selected==='' ) selected=true;
    for(var i=0;i<chk.length;i++) chk[i].checked=selected;
}
</script><form name=A method=POST>
1、<input name=song_ids type=checkbox value=1><BR>
2、<input name=song_ids type=checkbox value=2><BR>
3、<input name=song_ids type=checkbox value=3><BR>
4、<input name=song_ids type=checkbox value=4><BR>
5、<input name=song_ids type=checkbox value=5><BR>
<input type=button value='全  选A' onclick="selall_inform(song_ids)"> 
<input type=button value='全不选A' onclick="selall_inform(song_ids,false)"> 
</form>

解决方案 »

  1.   

    <body>
     <form>
     <input type=checkbox Name=Chk01  onpropertychange="selectAll('01',this.checked)">客户管理<br>
     <input type=checkbox Name=01>客户查看<br>
     <input type=checkbox Name=01>客户添加<br>
     <input type=checkbox Name=01>客户修改<br>
     <input type=checkbox Name=01>客户删除<br>
     </form>
     </body>
     <script>
     function selectAll(name,check){
    var objs=document.getElementsByName(name)
    for(var i=0;i<objs.length;i++) objs[i].checked=check
     }
     </script>
      

  2.   

    <script>
    function mycheck(obj)
    {
    for(i=0;i<document.all(obj.name.substring(3,5)).length;i++)
    document.all(obj.name.substring(3,5))[i].checked=obj.checked;
    }
    </script>
    <input type=checkbox name=Chk01 onchange="mycheck(this)" onclick="mycheck(this)">客户管理 
    <input type=checkbox name=01 value=0>客户查看 <input type=checkbox name=01 value=1>客户添加 <input type=checkbox name=01 value=2>客户修改 <input type=checkbox name=c01 value=3>客户删除<br> 
    <input type=checkbox name=Chk02 onchange="mycheck(this)" onclick="mycheck(this)">用户管理
    <input type=checkbox name=02 value=0>用户查看 <input type=checkbox name=02 value=1>用户添加 <input type=checkbox name=02 value=2>用户修改 <input type=checkbox name=02 value=3>用户删除