<script language="javascript">
function CountCheck()
{
  var num = 0;
  for(var i=0;i<document.all.length;i++)
  {
     if(document.all[i].type == "checkbox")
     {
       num = num+1;
     }
  }
  alert(num);
}
</script>

解决方案 »

  1.   

    http://community.csdn.net/Expert/topic/3577/3577670.xml?temp=.2451746
      

  2.   

    <script language="javascript">
    function checkCount()
    {
      var num = 0;
      for(var i=0;i<document.all.length;i++)
      {
         if(document.all[i].type.toLowerCase() == "checkbox")
         {
           num = num+1;
         }
      }
      alert(num);
    }
    </script><form name="form1" action="" method="post" onsubmit="checkCount()">
      

  3.   

    <script language="javascript">
    function OkClick(){
    var checksearch=eval("document.form1.search");

    if(checksearch==null){
    alert("请选择查询的项目,至少一项");
    return false;
    }
    if(checksearch.length){
    for(i=0;i<checksearch.length;i++){
    if(checksearch[i].checked){
    form1.submit();
    alert("您添的信息有误,请查询!!");
    return false;
    }
    }
    }
    else{
    if(form1.checksearch.checked){
    form1.submit();
    alert("nothing");
    return false;
    }
    }
    }
    </script>