title: How can I change the form action depending on javascript being enabled?
body: <p>I have a form that I want to default to calling a javascript ajax function to get the output. If the user doesn't have javascript enabled, I need to be able to recognize that and change the form action to a php page. Any idea on how to do this?</p>
  
  <pre><code>&lt;form class="form-inline" role="form" action="javascript:search();"&gt;
    &lt;div class="form-group"&gt;
      &lt;label class="sr-only" for="search"&gt;Search&lt;/label&gt;
      &lt;input type="text" class="form-control" id="search" placeholder="Search"&gt;
    &lt;/div&gt;
    &lt;button type="submit" class="btn btn-default"&gt;Search&lt;/button&gt;
  &lt;/form&gt;
  </code></pre>
  
  <p><code>search()</code> will get the form input and get the output through ajax without reloading the page. If javascript is not enabled, I will need to change the action to just <code>search.php</code>.</p>