title: Submitting a form from inside a JavaScript function in Tapestry
body: <p>I am trying to submit a form from inside a JavaScript function in Tapestry. 
  Here is the tml file. </p>
  
  <pre><code>&lt;!DOCTYPE html&gt;
  &lt;html xmlns:t="http://tapestry.apache.org/schema/tapestry_5_1_0.xsd" xmlns:tx="tapestry-library:tapx"&gt;
  &lt;head&gt;
      &lt;script type="text/javascript"&gt;
          function bodyLoaded () {
            document.form1.submit();
          }
      &lt;/script&gt;
  &lt;/head&gt;
  &lt;body onload="bodyLoaded()"&gt;
  &lt;form t:type="form" t:name="form1"&gt;
      &lt;select t:type="select" t:id="reportType" t:model="literal:A, B"&gt;&lt;/select&gt;
      &lt;input t:type="submit" id="clientSubmit" value="Generate"/&gt;
  &lt;/form&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>But I am getting below error, and the form is not getting submitted.</p>
  
  <blockquote>
    <p>document.form1 is undefined [Break on
    this error] document.form1.submit();</p>
  </blockquote>
  
  <p>So I looked at the html code generated by Tapestry. It has following tag:</p>
  
  <pre><code>    &lt;form onsubmit="javascript:Tapestry.waitForPage(event);" 
    action="test.form" method="post" id="form" name="form"&gt;
  </code></pre>
  
  <p>So I changed document.form1.submit() to document.form.submit(), but still it didn't solve the problem. Is there anything wrong with my code (or) doesn't hibernate allow to submit the form from inside JavaScript functions?</p>