title: Set form action dynamically depending on the field filled in by user
body: <p>I'd like to have a few different options that all map to different actions, but I only want one submit button.  I cannot for the life of me get this to work.  Here is the code I have so far:</p>
  
  <pre><code>&lt;!DOCTYPE html&gt;
  &lt;html lang="en-US"&gt;
  &lt;head&gt;
  &lt;link rel=stylesheet type=text/css href="{{ url_for('static', filename='css/main.css') }}"&gt;
  &lt;meta charset="UTF-8"&gt;
  &lt;/head&gt;
  &lt;body&gt;
  &lt;script type=text/javascript&gt;
  function clicked() {
      document.getElementById('id').action = "/query";
      document.getElementById('filename').action = "/fname";
      document.getElementById('dep').action = "/dependency";
      return true;
      }
  &lt;/script&gt;
  &lt;div id="header"&gt;
      &lt;h1&gt;TestPy&lt;/h1&gt;
  &lt;/div&gt;
  &lt;hr&gt;
  &lt;div id="wrapper"&gt;
      &lt;div class="query-menu" id="nav"&gt;
          &lt;form name="query_form" id="query" onsubmit="clicked()" method=post&gt;
              &lt;fieldset class="fieldset-auto-width"&gt;
                  &lt;legend&gt;Query&lt;/legend&gt;
                      &lt;table style="width:25%"&gt;
                      &lt;tr&gt;
                          &lt;td&gt;Plugin ID:&lt;/td&gt;
                          &lt;td&gt;&lt;input type=text name=script_id id="id" placeholder="19506"&gt;&lt;/td&gt;
                      &lt;/tr&gt;
                      &lt;tr&gt;
                          &lt;td&gt;Filename Search:&lt;/td&gt;
                          &lt;td&gt;&lt;input type=text name=filename id="fname" placeholder="test.file"&gt;&lt;/td&gt;
                      &lt;/tr&gt;
                      &lt;tr&gt;
                      &lt;td&gt;Dependency:&lt;/td&gt;
                      &lt;td&gt;&lt;input type=text name=dep id="dep" placeholder="dependency"&gt;&lt;/td&gt;
                         &lt;/tr&gt;
                         &lt;tr&gt;
                              &lt;th rowspan="2"&gt;&lt;td&gt;&lt;input type=submit value=Query class="btn"&gt;&lt;/td&gt;&lt;/th&gt;
                          &lt;/tr&gt;
                      &lt;/table&gt;
              &lt;/fieldset&gt;
          &lt;/form&gt;
      &lt;/div&gt;
      &lt;div class="content" id="section"&gt;
          {% block body %}{% endblock %}
      &lt;/div&gt;
  &lt;/div&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>What I'd like to do is have those three form fields each map back to a separate url, however I cannot get this to work.  If I take the javascript out and hard code the URL, it works fine.  HTML/JavaScript are not my strong language at all so I appreciate any feed back you can provide.  Thanks!</p>