title: How can I retrieve record without having to select the item and click in the input
body: <p>I am working on a jquery-ui autocomplete. I can start typing and from the first letter, a dropdown appears with matches. That part works correctly. My problem is, when you make a selection from the dropdown. I have tried <code>onchange</code> and <code>onselect</code> and they don't work. The code that gets the closest is <code>onclick</code>, but once you select an entry from the dropdown, in order for the script to retrieve the record from the database, you have to click again in the text input. Here is the code I described:</p>
  
  <pre><code>&lt;script type="text/javascript"&gt;
  $(function() {
  $( "#autocomplete" ).autocomplete({
  source: 'server.php'
  });
  });
  &lt;/script&gt;
  &lt;/head&gt;
  &lt;body&gt;
  &lt;div id="wrapper"&gt;
  &lt;div class="ui-widget"&gt; 
  &lt;input type="text" id="autocomplete" name="search" onclick="showMember(this.value)"&gt;
  &lt;/div&gt;
  &lt;/div&gt;
  &lt;div id="txtHint"&gt;&lt;/div&gt;
  &lt;script&gt;
  function showMember(str) {
  if (str == "") {
      document.getElementById("txtHint").innerHTML = "";
      return;
  } else { 
      if (window.XMLHttpRequest) {
          xmlhttp = new XMLHttpRequest();
      } else {
          xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
      }
      xmlhttp.onreadystatechange = function() {
          if (this.readyState == 4 &amp;&amp; this.status == 200) {
              document.getElementById("txtHint").innerHTML = this.responseText;
          }
      };
      xmlhttp.open("GET","catlist.php?name="+str,true);
      xmlhttp.send();
  }
  }
  &lt;/script&gt;
  </code></pre>
  
  <p><code>server.php</code> gets the data for the dropdown :</p>
  
  <pre><code>$connect=mysql_connect($host,$username,$password);
  $db=mysql_select_db($databasename);
  
  $searchTerm = $_GET['term'];
  
  $select =mysql_query("SELECT * FROM cmsb_markers WHERE name LIKE '".$searchTerm."%'");
  while ($row=mysql_fetch_array($select)) 
  {
  $data[] = $row['name'];
  }
  echo json_encode($data);
  </code></pre>
  
  <p>And <code>catlist.php</code> retrieves the record.</p>