title: How to submit a form on a link click using jquery?
body: <p>I'm working on a web search form which will return images and web results when they click on the link on top of the form.</p>
  
  <p>So I tried to trigger the form on a link click. Example: If they click image then am trying to submit the form with the image as an option. On the link click I am able to create the hidden input, but the submit itself is not triggered.</p>
  
  <p>Without hidden input I also tried the  <code>jQuery("#web_form").submit();</code>  which is not trigerring.</p>
  
  <p><strong>HTML &amp; FORM</strong></p>
  
  <pre><code>&lt;span class="web"&gt;&lt;a href="#"&gt;Web&lt;/a&gt;&lt;/span&gt;&lt;span class="image"&gt;&lt;a href="#"&gt;Image&lt;/a&gt;&lt;/span&gt;
  
  &lt;form method="post" id="web_form" action="&lt;?php echo $_SERVER['PHP_SELF'];?&gt;"&gt;  
  
  &lt;input type="submit" value="Search" name="submit"/&gt;
   &lt;?php            
              if (isset($_POST['submit'])) 
              {
                  $option = $_POST['searchoption'];
                  //perfoming statement based on option
              }
                 ?&gt;
      &lt;/form&gt;
  </code></pre>
  
  <p>jQuery</p>
  
  <pre><code>jQuery(document).ready(function(){
  
  jQuery('.web').click(function () {
    var option  = jQuery("&lt;input type='hidden' name='searchoption'/&gt;");
    option.val(jQuery(this).attr("class"));
    jQuery("#web_form").append(option).submit();  
    return false;
  });
  });
  </code></pre>
  
  <p>What is wrong in here?</p>
  
  <p>NOTE: Am trying this in wordpress does that make any sense?</p>
  
  <p><strong>EDIT</strong> after question posted</p>
  
  <pre><code>   jQuery(document).ready(function(){    
      jQuery('.web').click(function () {
        var option  = jQuery("&lt;input type='hidden' name='searchoption'/&gt;");
        option.val(jQuery(this).attr("class"));
        jQuery("#web_form").append(option).submit();  
        return false;
      });
       $( "#web_form" ).submit(function( event ) {
            alert( "Handler for .submit() called." );
       });
      });
  </code></pre>
  
  <p>I tried the above to make sure whether the form is submitted or not, when i click the link i'm getting the <code>Handler for .submit() called.</code> alert message. It seems to work the submit event but it is not submitting to external url in <code>action</code> field as well <code>&lt;?php echo $_SERVER['PHP_SELF'];?&gt;</code> in action.</p>
  
  <p>What is going on here? Any idea would be helpful.</p>