<script>
function CheckAll(frm)
  {
for (var i=0;i<frm.elements.length;i++)
{
var e=frm.elements[i];
if (e.type == 'checkbox' && e.disabled == false)
{
  e.checked = !e.checked;
}
}
  } 
</script>
<form>
<input type="checkbox" id="c1" disabled>
<input type="checkbox" id="c2" >
<input type="checkbox" id="c3" >
<input type="checkbox" id="c4" disabled>
<input type="checkbox" id="c5" ><input type="button" value="click" onclick="CheckAll(this.form)"></form>

解决方案 »

  1.   

    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=gb2312">
    <title>无标题文档</title>
    </head>
    <script type="text/javascript">
    function chk(){
    var chkname="";
    var tag=0;
    for(var i=0;i<frm.elements.length;i++){
    var e=frm.elements[i];
    if(e.type=="checkbox"&&e.checked){
    chkname+=e.name+"  ";
    tag++;
    }
    }
    if(tag==0) chkname="没有选中!"
    alert("你选中的复选框的name为:"+chkname);
    alert("个数为:"+tag)
    }
    </script>
    <body>
    <p>
    <form id="frm">
      <input type="checkbox" value="1" name="1">
      <input type="checkbox" value="2" name="2">
      <input type="checkbox" value="3" name="3">
    </p>
    <input type="button" id="btn" value="按钮" onClick="chk()">
    <p>
    </form>
    </body>
    </html>
    没选中可以自己写下!
      

  2.   

    <form name="" method=post action="">
    <input type="checkbox" name="a" value="">
    <input type="checkbox" name="a" value="">
    <input type="checkbox" name="a" value="">
    <input type="checkbox" name="b" value="">
    <input type="checkbox" name="b" value="">
    <input type="checkbox" name="b" value="">
    </form>
    <input type="button" value="按钮" onclick="test()">
    <br>
    <textarea id="Textarea1" rows="4" cols="80"></textarea>
    <script language="javascript">
    function test(){
        var es=document.all.tags("INPUT")
        var e
        var s=""
        for(i=0;i<es.length;i++){
            if(es[i].type=="checkbox"){
                s += (es[i].checked ? "√" : "×")
            }
        }
        Textarea1.value = s
    }
    </script>