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
http://www.erecoverydev.com/autocomp....tokeninput.js

My php file is:
Code:
<?
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.