title: Iterating through a html array in javascript
body: <p>Hi I have sevral selects on my page with the name viewer[].</p>
  
  <p>In javascript I wish to iterate through this array and get each ones selected index.</p>
  
  <pre><code>  var welements = document.getElementsByName('viewer[]')[0];
        for ( var i in welements )
          {
          alert(i.selectedIndex);
            } 
  </code></pre>
  
  <p>I have above but its clearly wrong. I beleive the first line is correct - document.getElementsByName returns an array so I just want the first (and only) result which is the viewer[] html array</p>
  
  <p>Advice appreciated, thanks!</p>