title: Submit without the use of a submit button, Mechanize
body: <p>So, I started out with Mechanize, and apparently the first thing I try it on is a monkey-rhino-level high JavaScript navigated site.</p>
  
  <p>Now the thing I'm stuck on is submitting the form.</p>
  
  <p>Normally I'd do a submit using the Mechanize built-in submit() function.</p>
  
  <pre><code>import mechanize
  
  browser = mechanize.Browser()
  browser.select_form(name = 'foo')
  browser.form['bar'] = 'baz'
  browser.submit()
  </code></pre>
  
  <p>This way it'd use the submit button that's available in the HTML form.</p>
  
  <p>However, the site I'm stuck on had to be one that doesn't use HTML submit buttons... No, they're trying to be JavaScript gurus, and do a submit via JavaScript.</p>
  
  <p>The usual submit() doesn't seem to work with this.</p>
  
  <p>So... Is there a way to get around this?</p>
  
  <p>Any help is appreciated. Many thanks!</p>
  
  <p>--[Edit]--</p>
  
  <p>The JavaScript function I'm stuck on:</p>
  
  <pre><code>function foo(bar, baz) {
      var qux = document.forms["qux"];
  
      qux.bar.value = bar.split("$").join(":");
  qux.baz.value = baz;
  qux.submit();
  }
  </code></pre>
  
  <p>What I did in Python (and what doesn't work):</p>
  
  <pre><code>def foo(browser, bar, baz):
      qux = browser.select_form("qux")
  
      browser.form[bar] = ":".join(bar.split("$"))
      browser.form[baz] = baz
      browser.submit()
  </code></pre>