sfraise Posted December 1, 2010 Share Posted December 1, 2010 I need to run this autocomplete script on multiple fields in a form. I created separate js and php files for each field and it seems to pull the values from the php file ok, when you don't have a match it correctly displays no results, however when you do have a match the suggestion box disappears in the first field. The last field works correctly. I'm assuming there is a var conflict between the script instances here and need to find a way around it. I've tried playing around with if else statements in both the php file and the js file to try and just use one but I can't get anything to work. You can view the script at www.erecoverydev.com/autocomplete2/js/jquery.tokeninput.js My php file is: <? mysql_pconnect("localhost", "username", "password") or die("Could not connect"); mysql_select_db("mydb") or die("Could not select database"); $param = mysql_real_escape_string ($_GET["q"]); $query = sprintf("SELECT cb_activities FROM jos_comprofiler WHERE cb_activities REGEXP '^$param'"); $arr = array(); $rs = mysql_query($query); while($obj = mysql_fetch_object($rs)) { $arr[] = $obj; } echo json_encode($arr); ?> There has to be a simple way to use multiple instances of this. Quote Link to comment https://forums.phpfreaks.com/topic/220400-how-to-use-autocomplete-script-on-mulitple-fields/ Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.