Jump to content

Recommended Posts

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.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.