title: Change value of input and submit form in JavaScript
body: <p>I'm currently working on a basic form. When you hit the submit button, it should first change the value of a field, and then submit the form as usual. It all looks a bit like this:</p>
  <pre><code>&lt;form name=&quot;myform&quot; id=&quot;myform&quot; action=&quot;action.php&quot;&gt;
      &lt;input type=&quot;hidden&quot; name=&quot;myinput&quot; value=&quot;0&quot; /&gt;
      &lt;input type=&quot;text&quot; name=&quot;message&quot; value=&quot;&quot; /&gt;
      &lt;input type=&quot;submit&quot; name=&quot;submit&quot; onclick=&quot;DoSubmit()&quot; /&gt;
  &lt;/form&gt;
  </code></pre>
  <p>And this is how far I've come with the JavaScript code. It changes &quot;myinput&quot;'s value to 1, but it does not submit the form.</p>
  <pre><code>function DoSubmit(){
    document.myform.myinput.value = '1';
    document.getElementById(&quot;myform&quot;).submit();
  }
  </code></pre>