title: How to submit a form with PhantomJS?
body: <p>I'm getting familiar with PhantomJS. But I can't get one thing. I have a page with a simple form:</p>
  
  <pre><code>&lt;FORM action="save.php" enctype="multipart/form-data" method="GET" onSubmit="return doSubmit();"&gt;
      &lt;INPUT name="test_data" type="text"&gt;
      &lt;INPUT name="Submit" type="submit" value="Submit"&gt;
  &lt;/FORM&gt;
  </code></pre>
  
  <p>and a save.php just writes down the test_data value</p>
  
  <p>so I'm doing this:</p>
  
  <pre><code>page.evaluate(function() {
      document.forms[0].test_data.value="555";
      doSubmit();
  });
  </code></pre>
  
  <p>When rendering the page I see that text field is 555, but form isn't submitting and save.php didn't write down a test_data value. So <code>doSubmit()</code> is not executing, is it? <code>doSubmit()</code> is a simple validation step and a submit is supposed to load the next page.</p>
  
  <p>So the question is: how can I execute a javascript code on the page, using PhantomJS?</p>