title: JavaScript Looping through select options
body: <p>I'm trying to loop through a select form to increase the value of the selected option whenever it is clicked. I've done some searching but I haven't found something I need..Here is the html</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>var counter = 0;
  function myFn(){
    var myOptionIndex = document.getElementById('selectForm').selectedIndex;
    var myOptionValue = document.getElementById('selectForm').value;
    var myOption = document.getElementById('selectForm').options;
  
    for (var i = 0; i &lt; myOption[myOptionValue].value; i++) {
      counter++;
    }
  
    document.getElementById('results').innerHTML = myOption[myOptionIndex].text 
    + " has been selected " + counter + " times";
  }</code></pre>
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;form action="" id="voteForm"&gt;
      &lt;select name="select-form" id="selectForm"&gt;
          &lt;option value="1"&gt; Option 1&lt;/option&gt;
          &lt;option value="1"&gt; Option 2&lt;/option&gt;
      &lt;/select&gt;
      &lt;button type="button" id="castVote" onclick="myFn();"&gt;Cast Your 
      Vote
     &lt;/button&gt;        
  &lt;/form&gt;
  &lt;div id="results"&gt;&lt;/div&gt;</code></pre>
  </div>
  </div>
  </p>