title: How to get the index of an option in a select menu by matching the text with plain Javascript?
body: <p>I have a select menu and I need to dynamically select the option based on the text value of the option element. For example, my select looks like this:</p>
  
  <pre><code>&lt;select id="names"&gt;
      &lt;option value=""&gt;Please Select&lt;/option&gt;
      &lt;option value="1"&gt;John&lt;/option&gt;
      &lt;option value="2"&gt;Steve&lt;/option&gt;
      &lt;option value="3"&gt;Max&lt;/option&gt;
  &lt;/select&gt;
  </code></pre>
  
  <p>If I have the string "Max", how can I get that the index of the option is 4 so I can dynamically set this as the selectedIndex with JavaScript?</p>
  
  <p>No jQuery.</p>