Submit form with a link using jQuery
<p>I have a small search form that can perform two types of searches:</p>

<pre><code>&lt;form id="form-navbar-search" class="navbar-search pull-left" action="index.cfm?fuseaction=Search.output" method="post"&gt;
   &lt;div class="input-append"&gt;
      &lt;input type="text" name="header_search_criteria" title="Criteria to search" placeholder="search" class="search-query span9" /&gt;
      &lt;input type="submit" name="quick" value="Quick" title="Search on task ID or task name" class="btn btn-inverse" /&gt;
      &lt;a href="index.cfm?fuseaction=Search.home" id="navbar-search-full" title="Start a full search" class="btn btn-inverse" /&gt;Full&lt;/a&gt;
   &lt;/div&gt;
&lt;/form&gt;
</code></pre>

<ol>
<li>If the "Quick" submit button is pressed, the form submits to the
default action attribute (<code>index.cfm?fuseaction=Search.output</code>). This works.</li>
<li>If
the "Full" button (it's really an <code>a</code> that I'm styling as a
button using Bootstrap) is pressed, I want to prevent the link from opening a new
page, change the form's action to <code>index.cfm?fuseaction=Search.home</code>, then submit the form. I have written this jQuery to do so:</li>
</ol>

<p>&nbsp;</p>

<pre><code>$('#navbar-search-full').click( function(event) {
   event.preventDefault(); //don't let the link open a new page
   $('#form-navbar-search').attr('action',  $(this).attr('href')).submit(); //instead, change the search form action, then submit it
})
.attr('href','#navbar-search-full');
</code></pre>

<p>As <a href="http://jsfiddle.net/jhfrench/cgcDy/" rel="nofollow">you can see in this JSFiddle</a>, the preventDefault() doesn't seem to intercept the link action. <strong>What adjustments do I need to make to get this right?</strong></p>
