title: Javascript form: call a specified submit button when a select field changes value
body: <p>I have a form with multiple submit buttons, one of which is a reload button that's proving hard to code.</p>
  
  <p>The idea is that when the user clicks "reload", the form is submitted, and it's updated based on the value of a select field. The code snippet for that bit is simple (cut down to basics):</p>
  
  <pre><code>&lt;select type="text" id="dataamount" size="1"&gt;
      &lt;option value="time0h10m"&gt;Latest 10 minutes&lt;/option&gt;
      &lt;option value="time1h00m"&gt;Latest 1 hour&lt;/option&gt;
      &lt;option value="time12h00m"&gt;Latest 12 hours&lt;/option&gt;
  &lt;/select&gt;
  &lt;input type="submit" id="btnreload" value="reload latest data"&gt;
  &lt;input type="submit" id="btndelete" value="delete all"&gt;
  &lt;input type="submit" id="btnrun" value="run"&gt;
  </code></pre>
  
  <p>Then I thought, if the user changes the "reload" field value, that should trigger submitting via the "reload" button anyway. (Why force them to change and <em>then</em> click, = 2 actions? Far nicer to trigger the submit automatically when dataamount -> onchange occurs.) But I'd have to specify which submit button, not just submit the form. That's the problem.</p>
  
  <p>I wanted to do something like this, but I gather this won't work or isn't reliable:</p>
  
  <pre><code>&lt;select type="text" id="dataamount" size="1" 
           onchange="document.getElementById('btnreload').submit();"&gt;
  etc
  
  or              "..... ('btnreload').click();
  </code></pre>
  
  <p>but I can't find any guide to do this, or giving the options I have. There are occasional hints that click() of a submit field may be poorly supported or submit fields can't always be executed using .submit().</p>
  
  <p>I'm after good compatibility and using pure javascript (no jquery etc). Ideally I'd like to keep it inline and avoid (enable/disable + form.submit()) workarounds if possible (submit buttons could change or become dynamic).</p>