Avatar of lhutton
lhutton

asked on 

Migrate jQuery Autocomplete to jQuery UI Autocomplete

How can I migrate the attached snippets of code from jQuery Autocomplete to jQuery UI Autocomplete using the Autocomplete Migration Guide?
<script language="JavaScript" type="text/javascript">
<!--//
 $(document).ready(function(){
	 $("#searchfield").autocomplete("include/ajax-functions.php",{max:999,minChars:2,extraParams: {action: "searchAutoComplete"}});
 });
//-->
</script>


* ajax-functions.php *
  case('searchAutoComplete'):
	 $fields = array('user_id','email','name_last');
	 $search = $_GET['q'];
	 $list = array();
     foreach ($fields as $this_field){
       $rs = mysql_query("SELECT * FROM $usertable WHERE " . $this_field . " LIKE \"$search%\" ORDER BY " . $this_field . " ASC");
       while ($row = mysql_fetch_array($rs)){
		  $list[] = $row["$this_field"];
	   }
	  }
      $rtn = array_unique($list); // remove any duplicates from results
	  echo implode("\n",$rtn); // return array as a multi-line string
	 break; // end searchAutoComplete

Open in new window

JavaScriptAJAXjQuery

Avatar of undefined
Last Comment
lhutton

8/22/2022 - Mon