title: How can I get a list of all values in select box?
body: <p>I am stumped. I have a form with a dropdown list, and I would like to grab a list of all the values in the list. I pulled the below example from w3 schools (yes, I know it's unreliable, but other solutions on stack overflow seem to be very similar to this). It was not working for me, and I tried plugging it into jsfiddle, but no luck.</p>
  
  <pre><code>HTML:
  &lt;form&gt;Select your favorite fruit:
      &lt;select id="mySelect"&gt;
          &lt;option value="a"&gt;Apple&lt;/option&gt;
          &lt;option value="o"&gt;Orange&lt;/option&gt;
          &lt;option value="p"&gt;Pineapple&lt;/option&gt;
          &lt;option value="b"&gt;Banana&lt;/option&gt;
      &lt;/select&gt;
  &lt;/form&gt;
  &lt;button type="button" onclick="displayResult()"&gt;Display text of all options&lt;/button&gt;
  </code></pre>
  
  <p>javascript:</p>
  
  <pre><code>function displayResult() {
      var x = document.getElementById("mySelect");
      var txt = "All options: ";
      var i;
      for (i = 0; i &lt; x.length; i++) {
          txt = txt + "\n" + x.options[i].value;
      }
      alert(txt);
  }
  </code></pre>
  
  <p>Not working on jsfiddle: <a href="http://jsfiddle.net/WfBRr/1/">http://jsfiddle.net/WfBRr/1/</a></p>
  
  <p>However, it works at their site: 
  <a href="http://www.w3schools.com/jsref/tryit.asp?filename=tryjsref_option_text2">http://www.w3schools.com/jsref/tryit.asp?filename=tryjsref_option_text2</a></p>
  
  <p>Any ideas on how to solve this?</p>