title: Change <form action> via JS
body: <p>I have a submit button outside the form. There is no way to place it within the form.
  I want to change the "action" attribute of the form via JS.</p>
  
  <p>HTML:
      
      </p>
  
  <pre><code>&lt;input type="button" value="Excel Export" onclick="excel_export('form_input','page2_xlsx.php')" /&gt;
  </code></pre>
  
  <p>JS:</p>
  
  <pre><code>function excel_export($formname,$formaction)
  {
      document.getElementsByName($formname)[0].formAction = $formaction;
      document.getElementsByName($formname)[0].submit();
  }
  </code></pre>
  
  <p>But this doesn't change the formaction and the action-page is still page2.php</p>
  
  <p>What's wrong with my code?</p>
  
  <p>Thanks!</p>