title: Send form after clicking on link
body: <p>I have an HTML form and i want to submit it using a link. The form has to be sent to the <code>href</code> of the link. This is my idea:</p>
  
  <p>Set a click event to the link <code>tag</code> which does the following:</p>
  
  <ul>
  <li>Blocks the default action of following the link.</li>
  <li>Edits the form by setting the action to the href of the link.</li>
  <li>Submits the form using jquery submit() function.</li>
  </ul>
  
  <p>I am looking for a solution where i don't have to change my html, only javascript.</p>
  
  <p>I tried this, but it doesn't work. Here is my code:</p>
  
  <p>Javascript:</p>
  
  <pre><code>jQuery('.row_header').find('td').each(function(){
      var cell = jQuery(this);
      cell.find('a').each(function(){
          //Get last link in cell. There is only one
          linkObject = jQuery(this);
      });     
  
      //Gets form
      var form = jQuery('#searchForm');
  
      if(typeof linkObject !== 'undefined'){
          //Get location url for form
          var url = linkObject.attr('href');
  
          linkObject.click(function(e){
              //Prevent default (following link)
              e.preventDefault(); 
              //Set location from link as form action     
              form.attr('action',url);
              //Submits form
              form.submit();
  
          });
      }
  });
  </code></pre>
  
  <p>HTML:</p>
  
  <pre><code>&lt;form id="searchForm"&gt;
      &lt;input type="text" name="myInput" value="myValue"&gt;
      &lt;input type="submit" name="mySubmit" value="mySubmitValue"&gt;
  &lt;/form&gt;
  
  &lt;table&gt;
      &lt;tr class="row_header"&gt;&lt;td&gt;&lt;a href="myLocation.php"&gt;The Link &lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;
  &lt;/table&gt;
  </code></pre>