title: Submitting a form with different values using javascript
body: <p>I am new to forms, and Javascript, so please be forgiving.</p>
  
  <p>I have a form that looks like this:</p>
  
  <pre><code>&lt;form method="post" action="control" name="myform"&gt;
  &lt;input type="submit" name="Name" value="Do A"/&gt;
  &lt;input type="submit" name="Name" value="Do B" /&gt;
  &lt;input type="submit" name="Name" value="Do C" /&gt;
  &lt;input type="submit" name="Name" value="Close" /&gt;
  &lt;/form&gt;
  </code></pre>
  
  <p>I need to change this so that there are two buttons, and the form is submitted using javascript dependent on some external conditions, so I want it to look something like this:</p>
  
  <pre><code>&lt;form method="post" action="control" name="myform"&gt;
  &lt;script&gt;
  function submitForm(form){
      if(someConditionA){
          submit the form so that the script performs same action as if the button Do A had been clicked
      } if (someConditionB){
          submit the form so that the script performs same action as if the button Do B had been clicked
      } if (someConditionC){
          submit the form so that the script performs same action as if the button Do C had been clicked
      }
  }
  
  function closeForm(form){
      window.close();
  }
  &lt;/script&gt;
  &lt;button name="doAction" onClick="SubmitForm(this.form)"&gt;Do Action&lt;\button&gt;
  &lt;button name="close" onClick="SubmitForm(this.form)"&gt;Close&lt;\button&gt;
  &lt;/form&gt;
  </code></pre>
  
  <p>How can I implement the function submitForm?</p>
  
  <p>Thanks</p>