How to dynamically change html form action value based on user input.

<span id="search">

    <form
      name="s"
      role="search"
      method="get"
      action="/search"
      onsubmit="return determineAction()"
    >
      <input id="searchString" name="q" placeholder="Enter text to search..." type="text"/>
      <input id="searchButton" name="submit" type="submit" value="GO"/>
    </form>

    <script type="text/javascript">
      function determineAction()
      {
        if (document.s.q.value != "")
        {
          document.s.action = "https://www.google.com/search";
        }
        return true;
      }
    </script>

</span>
TOPâ–˛
Post tagged with: html