title: text input change value and instant check
body: <p>I am wondering if it is <strong>possible to check the arrays</strong> and <strong>update the results div when the value of a textbox (input field) is changed</strong> without clicking submit.<br>
  In my attempt I have tried to use php and jQuery, however to no avail. I want to be able to check the arrays as soon as the user clicks a button and replacing the text in the input field (<code>$query</code>). <br>
  Is there any other way I can attempt this?
  <br>The code is as follows: <br></p>
  
  <pre><code>&lt;?php 
  //arrays
  $results = array();
  $results["car"] = array( "name" =&gt; "toyota");
  $results["food"] = array( "name" =&gt; "bread");
  $results["tool"] = array( "name" =&gt; "hammer");
  $query = "";
  ?&gt;
  &lt;script&gt;
  function colour() {
      document.getElementById("s").value = "colour";
  }
  function tool() {
      document.getElementById("s").value = "tool";
  }
  &lt;/script&gt;
  
  &lt;div id="form"&gt;
  &lt;input type="text" value="&lt;?php echo $query; ?&gt;" id="s" /&gt;
  &lt;/div&gt;
  
  &lt;button onclick="colour()"&gt;Check colours&lt;/button&gt;
  &lt;button onclick="tool()"&gt;Check tools&lt;/button&gt;
  
  
  
  
  &lt;div id="result"&gt;
  &lt;?php  
           foreach ($results as $key =&gt; $val) {
             if ($key === $query) {
                 echo " match found! for " . $key;
             }
           }
      ?&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p><strong>I look forward for your input.</strong> :)</p>