Solved

Small problem with nodstrum.com AJAX autocomplete/sugges function

Posted on 2007-11-29
14
568 Views
Last Modified: 2013-12-12
Been poking around all day 'learning' and finally found an autocomplete function that I can work with.  Got it at  http://nodstrum.com/2007/09/19/autocompleter/

Got it all installed and it works perfectly, got it re-configured only to find out it didn;t fill in the input when I clicked a choice from the popup list.  Switched it back to irf\ginal version and same thing, nada.  So my question is, simply what could possibly be wrong with the fill() function?  It works on the site demo, so I am assuming it should work on mine :)  I can post code, but the only changes I made were to the MySQl server setting, database and table and field names.  Never even touched the js file...  

Little help? TIA if you can...

Owen
0
Comment
Question by:owenparker
  • 7
  • 7
14 Comments
 
LVL 21

Expert Comment

by:nizsmo
ID: 20379907
Hi owenparker

It sounds like you haven't changed much. Often a good way is to change only one thing at a time and after the thing you change, try the script and make sure the change doesn't stop the script from working. This way you will know exactly which changes will work fine and which changes you made has caused the problem.

Hope this helps.
0
 

Author Comment

by:owenparker
ID: 20380872
I actually went back to the original code downloaded and the same issue was present.  Thus my quandry...  Thanx for the reply, however...
0
 
LVL 21

Expert Comment

by:nizsmo
ID: 20380881
you cannot run the code even at its default?
0
 

Author Comment

by:owenparker
ID: 20380935
I just re-downloaded original zip and got the demo working.  won;t be long now i suspect :)
0
 
LVL 21

Expert Comment

by:nizsmo
ID: 20380941
goodluck, 1 step/change at a time :)
0
 

Author Comment

by:owenparker
ID: 20380955
ok, got the demo working, changed my table to have the same column name, data type, size, etc as the sample code table so all i changed in the sample code was the actual table name in the select statement.  the suggestion list comes up as expected but when i click, the chosen result will not fill the field???!!!  Now I am very stumped.  ARGH!
0
 
LVL 21

Expert Comment

by:nizsmo
ID: 20380969
did the original unmodified example fill the field properly?
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 

Author Comment

by:owenparker
ID: 20380971
ok, finally some success.  some of the entries work, some don't.  the only oddity i can see with the ones that don't fill would be an apostrophe.  How exactly may i get around this?
0
 
LVL 21

Expert Comment

by:nizsmo
ID: 20380976
then you probably need to escape the apostrophe character by putting "\" the escape character before it.
Eg:
\'
0
 

Author Comment

by:owenparker
ID: 20380991
it's definitely the apostrophe.  Where exactly would I escape it?  I slipped in the code where it is building the suggestion box...
$query = $db->query("SELECT value FROM inventory WHERE value LIKE '%$queryString%'");

if($query) {

   // While there are results loop through them - fetching an Object (i like PHP5 btw!).

   while ($result = $query ->fetch_object()) {

           // Format the results, im using <li> for the list, you can change it.

           // The onClick function fills the textbox with the result.
 

           // YOU MUST CHANGE: $result->value to $result->your_colum

   echo '<li onClick="fill(\''.$result->value.'\');">'.$result->value.'</li>';

}

Open in new window

0
 
LVL 21

Accepted Solution

by:
nizsmo earned 500 total points
ID: 20381004
Try this.

Also you missed a closing bracket, may have just been your copy and paste error.
<?php

	$query = $db->query("SELECT value FROM inventory WHERE value LIKE '%$queryString%'");

if($query) {

   // While there are results loop through them - fetching an Object (i like PHP5 btw!).

   while ($result = $query ->fetch_object()) {

           // Format the results, im using <li> for the list, you can change it.

           // The onClick function fills the textbox with the result.

 

           // YOU MUST CHANGE: $result->value to $result->your_colum

   echo '<li onClick="fill(\''.addslashes($result->value).'\');">'.addslashes($result->value).'</li>';

}

}

?>

Open in new window

0
 

Author Closing Comment

by:owenparker
ID: 31411863
Timely response, and near-live back and forth.  A small problem that caused a lot of trouble solved :)
0
 

Author Comment

by:owenparker
ID: 20381100
Thanx a mil' nizsmo.  This small thing had me really stumped.  Very nice to have someone to bounce things off.  Your help was very much appreciated, my brother...
0
 
LVL 21

Expert Comment

by:nizsmo
ID: 20381108
no problems at all, glad to be of assistance! :)
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I imagine that there are some, like me, who require a way of getting currency exchange rates for implementation in web project from time to time, so I thought I would share a solution that I have developed for this purpose. It turns out that Yaho…
Introduction This article is intended for those who are new to PHP error handling (https://www.experts-exchange.com/articles/11769/And-by-the-way-I-am-New-to-PHP.html).  It addresses one of the most common problems that plague beginning PHP develop…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…

863 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

25 Experts available now in Live!

Get 1:1 Help Now