先把范围缩小,然后通过分析childNodes来筛选

解决方案 »

  1.   

    var navRoot = document.getElementById("menu").getElementsByTagName("LI");
      

  2.   

    可以获取到所有form再根据它的属性去 区分
      

  3.   

    我是个新手,不太明白,大家能否直接帮我改以下javascript , 把它定位在某个form上呢:function   foo(e)   {   
          var input_cart=document.getElementsByTagName("INPUT");
      var input_all=0;
          for   (var   i=0;   i<input_cart.length;   i++)   {   
              if   (input_cart[i].type=="text"   &&   input_cart[i].value!="")   {
      
                  input_all=input_all+1;   
              //alert(input_all);
              }   
          }
      if (input_all==0)
      {
      alert("Please input one of the quantity of products that you want before you submit,thanks!");
      return false;
      }
      }
      

  4.   

    真的不知道该怎么办,麻烦好心人帮忙下吧。或者直接用你们的方法,能判断相应form中的值就行
      

  5.   

    childNodes这个我没有用过呢,也不知道该方法是否能支持有所常用浏览器呢。
      

  6.   

    document.getElementById("pro_search").getElementsByName("input");
      

  7.   

    先确定哪个form_id,在确定form中的子结点input
    var navRoot = document.getElementById("form_id").getElementsByTagName("input");
      

  8.   

    我改成以下后,代码好象不起作用了:
    function   foo(e)   {   
          var input_cart=document.getElementById("pro_search").getElementsByTagName("input");
      var input_all=0;
          for   (var   i=0;   i <input_cart.length;   i++)   {   
              if   (input_cart[i].type=="text"   &&   input_cart[i].value!="")   {
      
                  input_all=input_all+1;   
              //alert(input_all);
              }   
          }
      if (input_all==0)
      {
      alert("Please input one of the quantity of products that you want before you submit,thanks!");
      return false;
      }
      }
      

  9.   

    demox 老兄的答案,应试是正确的吧,我支持
      

  10.   

    测试成功。呵。  我把getElementsByTagName("input");搞成了getElementsByName("input") 。呵呵。终于好了。谢谢了。这个代码真难用。第一次用,而且超长,本人不看书所以很多基础不懂。谢谢请教了。