title: Ajax and Textbox change event
body: <p>I am developing an entry form. In the form there are two textbox. In one textbox when I type a keyword a DIV is opened and customer list having customerid and customername is displayed.</p>
  
  <pre><code>&lt;form name="form1" action=""&gt; 
  customerid : &lt;input type=text id="cusid" /&gt;
  customername: &lt;input type="text" id="custnm" onkeyup="showHint(this.value);" /&gt;
  &lt;/form&gt;
  
  
  &lt;div id="txtHint" style="width:250; background-color:cyan; display:none; "&gt;
  
  &lt;/div&gt;
  </code></pre>
  
  <p>The customer list is displayed using ajax. Now in the list I have hyperlink on the CustomerID. </p>
  
  <p>I want to return the customerID from the list back to the cusid textbox when user clicks the link. Also when user hits the tab button controls should transfer to the customer list. the same trigger should fire when user hits enter button and selected customerid should get filled in CUSId textbox.</p>
  
  <p>Below is the procedure for ajax.</p>
  
  <pre><code>function showHint(str) {
  
    var xhttp;
    if (str.length == 0) { 
      document.getElementById("txtHint").innerHTML = "";
      return;
    }
    xhttp = new XMLHttpRequest();
    xhttp.onreadystatechange = function() {
      if (xhttp.readyState == 4 &amp;&amp; xhttp.status == 200) {
        document.getElementById("txtHint").style.display="inline";
        document.getElementById("txtHint").innerHTML = xhttp.responseText;
      }
    };
    xhttp.open("post", "getemp.asp?q="+str+"", true);
    xhttp.send();   
  }
  </code></pre>
  
  <p>this is the getemp.asp file</p>
  
  <pre><code>sernm=request("q")
  response.Write "&lt;table&gt;"
  ks.open "select customer,customerid from customer where customername like '"&amp;sernm&amp;"%'",conn
  if not ks.eof then
  while not ks.eof
      vid=ks(1):if isnull(vid) or trim(vid)="" then vid=0
      acname=ks(0)
      'response.Write empnm &amp;"&amp;nbsp;"&amp; ad1 &amp;"&amp;nbsp;"&amp; ad2 &amp;"&amp;nbsp;"&amp; ad3 &amp;"&lt;br&gt;"  
      response.Write "&lt;tr&gt;"
      %&gt;
      &lt;td&gt;&lt;a href="" onclick="return CloseWind('12');" &gt;&lt;%=vid%&gt;&lt;/a&gt;&lt;/td&gt;
      &lt;%
      response.Write "&lt;td&gt;"&amp;acname&amp;"&lt;/td&gt;"
      response.Write "&lt;/tr&gt;"
  
      ks.movenext
  wend
  end if
  ks.close
  response.Write "&lt;table&gt;"
  </code></pre>
  
  <p>This is the javascript for getting customerID</p>
  
  <pre><code>&lt;script language="javascript"&gt;
  function CloseWind(VID)
  {
      document.forms['form1'].elements[CUSID].value=VID;
      return false;
  }   
  &lt;/script&gt;
  </code></pre>
  
  <p>How could i get the customerid in the main form.</p>
  
  <p>This is the same when we try to do voucher entry in tally.</p>