title: Document.getElementByName for array
body: <p>I want to create a loop over element in javascript ,
  my html is:</p>
  
  <pre><code>&lt;input type="checkbox" name="menu[]" value="0"&gt;
  &lt;input type="checkbox" name="menu[]" value="1"&gt;
  &lt;input type="checkbox" name="menu[]" value="2"&gt;
  </code></pre>
  
  <p>and javascript is</p>
  
  <pre><code>window.onload = function() {
      var x = document.getElementsByName("menu");
      for (i = 0; i &lt; x.length; i++) {
          if (x[i].type == "checkbox") {
              x[i].checked = true;
          }
      }
  
  }
  </code></pre>
  
  <p>but no element was detected!!!!
  try <code>alert(x.length)</code> and you seen 0!!</p>