title: How to submit a form using javascript
body: <p>I'm trying to click on a submit button and submit a form using purely javascript. I have tried:</p>
  
  <pre><code>document.getElementById('sell_form').submit();
  </code></pre>
  
  <p>and</p>
  
  <pre><code>for(var i=0;i&lt;document.getElementsByName('operation').length;i++){
      if(document.getElementsByName('operation')[i].value=='Sell'){
          document.getElementsByName('operation')[i].submit();
      }
  }
  </code></pre>
  
  <p>but I just can't get it. Can anyone show me how I could do this?</p>
  
  <p>Thanks in advance.</p>
  
  <p>The web code is:</p>
  
  <pre><code>&lt;form id="sell_form" class="ajaxform" action="/member/sell" method="post"&gt;
      &lt;div id="result" class="popup"&gt; &lt;/div&gt;  //hidden
      &lt;div class="c-box-body"&gt;
          &lt;table width="100%" border="0"&gt;
          &lt;div style="text-align:center"&gt;
              &lt;br&gt;
              &lt;input type="hidden" value="13" name="pair"&gt;    //hidden
              &lt;input type="hidden" value="Sell" name="type"&gt;  //hidden
              &lt;input type="submit" value="Calculate" name="calculate"&gt;
              &lt;input type="submit" value="Sell" name="operation"&gt;   //**This is the one I'm trying to click on
              &lt;input type="reset" value="Clear"&gt;
          &lt;/div&gt;
      &lt;/div&gt;
  &lt;/form&gt;
  </code></pre>
  
  <p>What makes this difficult is that the web page is not mine (I'm using greasemonkey in firefox which is essentially and onload javascript event)</p>