title: How to get search bar to take input and go to page
body: <p>I'm trying to get a search box that when it takes an input it sends the user to a specific page. But for some reason that, I cannot figure out, it doesn't do anything when an input is given. My code is the following:</p>
  
  <pre><code>&lt;!DOCTYPE html&gt;
  &lt;html&gt;
      &lt;head&gt;
          &lt;title&gt;TEST&lt;/title&gt;
          &lt;script type="text/javascript"&gt;
              var input = document.getElementById("search");
  
              function sendToPage(){
                  if (input.value == "happy"){
                      location.href="suggestion_happy.html";
                  }
                  else if (input.value == "sad"){
                      location.href="suggestion_sad.html";
                  }
                  else {
                      alert('Invalid Input.');
                  }
                      }
          &lt;/script&gt;
      &lt;/head&gt;
      &lt;body&gt;
          &lt;div&gt;
              &lt;form onsubmit="sendToPage()"&gt;
                  &lt;input type="text" method="put" id="search" placeholder="Search" value=""&gt;
              &lt;/form&gt;
          &lt;/div&gt;
      &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>Please help I'm still kind of new to javascript :)</p>