title: JavaScript -- clear form after values are submitted
body: <p>I am using the following JavaScript code to clear a form on my page.</p>
  
  <pre><code>document.getElementById("bulletinForm").reset();
  </code></pre>
  
  <p>This code does indeed clear my form, but it does it before the information is sent to the server.  I've tried calling as the onSubmit event on the form and as the onClick event on the Submit button.  How do I send the information to the server before clearing the form?  I am not currently using any Ajax with this.  All I have is a Spring form that looks like this.</p>
  
  <pre><code>&lt;form:form commandName="bulletin" method="post" action="processBulletin"&gt;
      &lt;table&gt;
          &lt;tr&gt;
              &lt;td&gt;Name: &lt;font style="font-weight: bold; color: red;"&gt;
              &lt;c:out value='${nameRequired}' /&gt;&lt;/font&gt;&lt;br /&gt;&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;form:input path="name" id="name" maxlength="100" value="" /&gt;&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;Subject: &lt;font style="font-weight: bold; color: red;"&gt;
              &lt;c:out value='${subjectRequired}' /&gt;&lt;/font&gt;&lt;br /&gt;&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;form:input path="subject" id="subject" maxlength="1000" value="" /&gt;&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td valign="top"&gt;Message: &lt;font style="font-weight: bold; color: red;"&gt;
              &lt;c:out value='${messageRequired}' /&gt;&lt;/font&gt;&lt;br /&gt;&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;                            
              &lt;td&gt;&lt;form:textarea path="note" id="note" cols="80" rows="100" value="" /&gt;&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;input type="submit" value="Submit bulletin" onClick="clearForm()"/&gt;&lt;/td&gt;
          &lt;/tr&gt;
      &lt;/table&gt;
  &lt;/form:form&gt;
  </code></pre>