var length =  document.form1.id?document.form1.id.length?document.form1.id.length:1:0

解决方案 »

  1.   

    我知道,
    document.form1.id1.length
      

  2.   

    <form name="form1">
    </form>
    <script>
    alert(document.getElementsByName("id1").length)
    </script>
      

  3.   

    var a = document.form1.elements;
    var n = 0;
    for(var i=0; i<a.length; i++)
      if(a[i].tagName=="INPUT" && a[i].type=="radio") n++;
    alert("form1 表单里共有 "+ n +" 个 radio 单选框!");To宝宝: 若是有很多 radio 但不同 name 的话, 你的方法得调多次了, 还不如这么一个循环
      

  4.   

    document.form1.id.length
    我以为是要特定name的radio的个数 :)
      

  5.   

    document.getElementsByTagName("radio").length