title: Javascript select array length
body: <p>I had posted a long question here <a href="https://stackoverflow.com/questions/14995314/form-validation-multidimensional-objects/14995478#14995478">Form validation multidimensional select boxes</a></p>
  
  <p>a short problem is, I am allowing users to add multiple rows for data input. Each row have  </p>
  
  <pre><code>&lt;select name="color[]"&gt;
     &lt;option&gt;1&lt;/option&gt;
     &lt;option&gt;2&lt;/option&gt;
     &lt;option&gt;3&lt;/option&gt;
     &lt;option&gt;4&lt;/option&gt;
  &lt;/select&gt;
  </code></pre>
  
  <p>If there are 3 select boxes i can get its length by using <code>frm["color[]"].length</code> and it will return 3. </p>
  
  <p>But if there is only 1 select box <code>frm["color[]"]</code> will return me number of options from the select and return me 4</p>
  
  <p><strong>EDIT</strong></p>
  
  <p>used <code>document.getElementsByName("color[]")</code> and it worked. Thank you kolink, </p>
  
  <pre><code>    colors= document.getElementsByName("colors[]").length;
  
      console.log(colors); // print proper numbers now
      for(i=0; i&lt;colors; i++){
          dd = frm["colors["+i+"]"].value; // &lt;- how to check value
          console.log(dd);
          k = i+1;
          var subColors = document.getElementsByName("colors["+k+"][]").length
  
      }
  </code></pre>
  
  <p>How i can get the value of selected option from select box </p>