title: Query database with Ajax and classic ASP
body: <p>I'm trying to modify a script from w3scools to use a combination of asp and ajax to query a database and return results.</p>
  
  <p>Here is the code:</p>
  
  <pre><code>&lt;html&gt;
  &lt;head&gt;
  &lt;script type="text/javascript"&gt;
  function showCustomer(str)
  {
      var xmlhttp;    
      if (str=="")
      {
          document.getElementById("txtHint").innerHTML="";
          return;
      }
      if (window.XMLHttpRequest)
      {// code for IE7+, Firefox, Chrome, Opera, Safari
          xmlhttp=new XMLHttpRequest();
      }
      else
      {// code for IE6, IE5
          xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
      }
      xmlhttp.onreadystatechange=function()
      {
          if (xmlhttp.readyState==4 &amp;&amp; xmlhttp.status==200)
          {
              document.getElementById("txtHint").innerHTML=xmlhttp.responseText;
          }
      }
      xmlhttp.open("GET","getcustomer.asp?q="+str,true);
      xmlhttp.send();
  }
  &lt;/script&gt;
  &lt;/head&gt;
  &lt;body&gt;
  
  &lt;form action=""&gt; 
      &lt;select name="customers" onchange="showCustomer(this.value)"&gt;
          &lt;option value=""&gt;Select a customer:&lt;/option&gt;
          &lt;option value="ALFKI"&gt;Alfreds Futterkiste&lt;/option&gt;
      &lt;/select&gt;
  &lt;/form&gt;
  &lt;br /&gt;
  
  &lt;div id="txtHint"&gt;Customer info will be listed here...&lt;/div&gt;
  
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>I would like to replace the select field with 2 input fields.</p>
  
  <p>Can someone please tell me how to amend the javascript so that both the input values are passed with the querystring and what needs to be changed on the form to call the function.</p>
  
  <p>Thanks</p>