title: How to change options of a select using JavaScript
body: <p>I have an HTML page in which I have 2 <code>select</code>s.  </p>
  
  <pre><code>&lt;select id="field" name="field" onchange="checkValidOption();"&gt;
      &lt;option /&gt;
      &lt;option value="Plugin ID"&gt;Plugin ID&lt;/option&gt;
      &lt;option value="Name"&gt;Name&lt;/option&gt;
  &lt;/select&gt;
  &lt;select id="operator" name="operator" onchange="checkValidOption();"&gt;
      &lt;option /&gt;
      &lt;option value="EQUALS"&gt;EQUALS&lt;/option&gt;
      &lt;option value="CONTAINS"&gt;CONTAINS&lt;/option&gt;
      &lt;option value="NOT CONTAINS"&gt;NOT CONTAINS&lt;/option&gt;
      &lt;option value="REGEX"&gt;REGEX&lt;/option&gt;
  &lt;/select&gt;
  </code></pre>
  
  <p>What I'd like to happen is that <code>checkValidOption()</code> could make it so that if "Plugin ID" is selected in field that the only option is EQUALS (and it's selected) and otherwise all the other options are available.  Any idea on how to approach this?</p>
  
  <p>I tried changing the <code>innerHTML</code> of the operator select in JS:</p>
  
  <pre><code>document.getElementById("operator").innerHTML =
      "&lt;option value='EQUALS'&gt;EQUALS&lt;/option&gt;";
  </code></pre>
  
  <p>However this results in an empty <code>select</code> (this would also include manually setting the many <code>option</code>s for going back to having all the ones listed above).  </p>
  
  <p>I can't think of another solution, any help would be greatly appreciated.</p>