title: Reset all select dropdowns
body: <p>I have have a function that gets called by onbeforeunload. Within I wish to reset all the dropdowns but I cannot find the right method to reset them back to the 0 value.</p>
  
  <pre><code>&lt;head&gt;
      &lt;script type="text/javascript"&gt;
          function displaymessage() {
              document.getElementsByTagName('select').value = 1;
              //or
              document.getElementsByTagName('select').options.length = 0;
          }
      &lt;/script&gt;
  &lt;/head&gt;
  
  &lt;body&gt;
      &lt;form&gt;
          &lt;input type="button" value="Click me!" onclick="displaymessage()" /&gt;
      &lt;/form&gt;
  
      &lt;select name="data[Rate][15][12][num_rooms]" id="r15ro12"&gt;
          &lt;option value="0"&gt;0&lt;/option&gt;&lt;option value="1"&gt;1 Rooms&lt;/option&gt;
          &lt;option value="2"&gt;2 Rooms&lt;/option&gt;&lt;option value="3"&gt;3 Rooms&lt;/option&gt;&lt;option value="4"&gt;4 Rooms&lt;/option&gt;
          &lt;option value="5"&gt;5 Rooms&lt;/option&gt;&lt;option value="6"&gt;6 Rooms&lt;/option&gt;&lt;option value="7"&gt;7 Rooms&lt;/option&gt;
          &lt;option value="8"&gt;8 Rooms&lt;/option&gt;&lt;option value="9"&gt;9 Rooms&lt;/option&gt;
      &lt;/select&gt;
  
      &lt;select name="data[Rate][15][12][num_rooms]" id="r15ro12"&gt;
          &lt;option value="0"&gt;0&lt;/option&gt;&lt;option value="1"&gt;1 Rooms&lt;/option&gt;
          &lt;option value="2"&gt;2 Rooms&lt;/option&gt;&lt;option value="3"&gt;3 Rooms&lt;/option&gt;&lt;option value="4"&gt;4 Rooms&lt;/option&gt;
          &lt;option value="5"&gt;5 Rooms&lt;/option&gt;&lt;option value="6"&gt;6 Rooms&lt;/option&gt;&lt;option value="7"&gt;7 Rooms&lt;/option&gt;
          &lt;option value="8"&gt;8 Rooms&lt;/option&gt;&lt;option value="9"&gt;9 Rooms&lt;/option&gt;
      &lt;/select&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>