title: Javascript: Why is FOR loop skipping every other match?
body: <p>I'm currently getting 5 results from my <code>.getElementsByName()</code> query, and looping though them proceeds as expected when throwing a simple <code>alert()</code>, but as soon as I try to set new names for those results, it's skipping my second and fourth matches.</p>
  
  <p><strong>SOURCE:</strong></p>
  
  <pre><code>&lt;form&gt;
      &lt;input type="text" /&gt;
      &lt;input type="checkbox" name="target" value=1 /&gt;
      &lt;input type="checkbox" name="target" value=2 /&gt;
      &lt;input type="checkbox" name="target" value=3 /&gt;
      &lt;input type="checkbox" name="target" value=4 /&gt;
      &lt;input type="checkbox" name="target" value=5 /&gt;
      &lt;input type="text" /&gt;
      &lt;input type="checkbox" name="test" /&gt;
      &lt;input type="checkbox" name="test" /&gt;
      &lt;input type="checkbox" name="test" /&gt;
  &lt;/form&gt;
  </code></pre>
  
  <p><br>
  When I try:</p>
  
  <pre><code>window.onload = function() {
      var fields = document.getElementsByName("target");
  
      for (var i = 0; i &lt; fields.length; i++) {
          alert( fields[i].value );
      }
  }
  </code></pre>
  
  <p>It throws an alert for all five values.</p>
  
  <p><br>
  HOWEVER, when I try this instead:</p>
  
  <pre><code>for (var i = 0; i &lt; fields.length; i++) {
      fields[i].name = 'target[]';
  }
  </code></pre>
  
  <p>it only renames every other one (0,2,4).</p>
  
  <p>What am I missing?</p>