将id值设置成一样的,用getElementbyId

解决方案 »

  1.   

    <script language="javascript">
    <!--
      function funcheck()
      {
        var ingc;
        for (ingc=0;ingc<document.all.length;ingc++)
        {
          if (document.all(ingc).type == 'checkbox') 
          {
            alert("找到的checkbox的名为:"+document.all(ingc).name);
           }
        }
      }
    //-->
    </script><input type=checkbox name=C1>
    <input type=checkbox name=C2>
    <input type=checkbox name=C3>
    <input type=checkbox name=C4>
    <input type=checkbox name=C5>
    <input type=button name=B1 value=check onclick="funcheck();">
      

  2.   

    <form>
    <input type="checkbox" name="">
    <input type="checkbox" name=""><input type="checkbox" name=""><input type="checkbox" name=""><input type="checkbox" name=""><input type="checkbox" name=""><input type="checkbox" name=""><input type="password"><input type="radio" name=""><input type="password"><input type="checkbox" name=""><input type="reset"><input type="password"><input type="checkbox" name=""><input type="password">
    </form>
    <input type="button" onclick="for(var i=0,j=0, obj=document.getElementsByTagName('INPUT');i<obj.length;i++){if(obj[i].type=='checkbox'){j++};};alert(j)">
      

  3.   

    or~~~
    <script language="javascript">
    <!--
      function funcheck()
      {
         var o = document.getElementsByName("D1");
         var ingc;
         for (ingc=0;ingc<o.length;ingc++) 
         {
           if (o[ingc].type == 'checkbox')
           alert("检索到的checkbox的名为:"+o[ingc].name);
         }
      }
    //-->
    </script><input type=checkbox name=C1 id=D1>
    <input type=checkbox name=C2 id=D1>
    <input type=checkbox name=C3 id=D1>
    <input type=checkbox name=C4 id=D1>
    <input type=checkbox name=C5 id=D1>
    <input type=button name=B1 value=check onclick="funcheck();">
      

  4.   

    checkbox的name设成一样就可以了啊
      

  5.   

    mjpclab(我是大猫猫啊 http://mjpclab.8u8.com)type 返回的是 [object],不是 checkbox你确定  :)
      

  6.   

    不用typeof()的话,不会返回[object]呀
    zltostem(尘寞)的方法我试了,可以的