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>
        <input id="searchButton" name="submit" type="submit" value="GO"></input>
    </form>

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

</span>
BACK TO TOP
Post tagged with: html