title: Loop over Dropdownlist
body: <p>I want to loop over a Dropdownlist and write the value of the selected Item in a label.
  I've done it before with a selection of Radio buttons but with the dropdownlist it won't work.
  Now, some Code.</p>
  
  <p>Here is the generated HTML Code Values are not interesting.</p>
  
  <pre><code>&lt;select id="alternativeNumbers" name="alternativeNumbers"&gt;
     &lt;option value="1_A"&gt;Text&lt;/option&gt;
     &lt;option value="2_B"&gt;Text&lt;/option&gt;
     &lt;option value="3_C"&gt;Text&lt;/option&gt;
     &lt;option value="4_D"&gt;Text&lt;/option&gt;
     &lt;option value="5_E"&gt;Text&lt;/option&gt;
     &lt;option value="6_F"&gt;Text&lt;/option&gt;
  &lt;/select&gt;
  </code></pre>
  
  <p>The Code to bind the event to the Dropdownlist.</p>
  
  <pre><code>$(function () {
      var dropdown = document.getElementsByName("alternativeNumbers");
      $(dropdown ).change(function () {
          updateAlternativeDropdown();
      });
  });
  </code></pre>
  
  <p>And finally the method which is called by the event. This should fill the labels.</p>
  
  <pre><code>function updateAlternativeDropdown() {
      var dropdown = document.getElementsByName("alternativeNumbers");
      var lengthDropDown = addAlternativeArticleNumberDropdown.length;
      for (var i=0; i &lt; lengthDropDown; i++) 
      {
          //This alert is for the behavior of the output!
          alert(addAlternativeArticleNumberDropdown[i].value);
          if (addAlternativeArticleNumberDropdown[i].selected) {
              var valueOfDropdown = addAlternativeArticleNumberDropdown[i].value;
              var splittedValues = valueOfDropdown.split("_");
              document.getElementById("label1").innerText = splittedValues[0];
              document.getElementById("label2").innerText = splittedValues[1];
          }
      }
  };
  </code></pre>
  
  <p><strong>I hope this is enough information, now the Problem / Current behavior:</strong></p>
  
  <p>The method updateAlternativeDropdown() is called fine but then the alert inside the loop returns the value of first element, value of the selected element and this 3 times. (I guess because of the 6 elements in this element)</p>
  
  <p>Furthermore because of this my if-statement isn't entered. Currently I#m kind of clueless where this problem comes from.</p>
  
  <p>Thanks in advance.</p>