Database Driven Autocomplete
Moderator: General Moderators
Database Driven Autocomplete
How are those auto complete boxes made where it gueses what you want by searching out a database and displaying back the result which like each letter you enter it narrows down what you are trying to search for?
How do you override auto complete so that even if the users browser has it turned on, you can disable it?
How do you override auto complete so that even if the users browser has it turned on, you can disable it?
Re: Database Driven Autocomplete
It seems like you are confusing between 2 different things 
Re: Database Driven Autocomplete
I'm not sure if you mean autocomplete as in search boxes on websites that use AJAX, or autocomplete like something google has. If it's a software the user has installed themselves I'm not sure there is a way to turn it off. If the website in question is using AJAX then I think if you turn your javascript off you may be able to turn off those features but then the site may not work. I dunno, I'm not all that familiar with AJAX and how it works but I do know its based off of Javascript.
Re: Database Driven Autocomplete
Im curious on how to do the AJAX auto complete.
Re: Database Driven Autocomplete
Well I'm not an expert on AJAX but I know it has to do with opening a persistent connection to the server and then using XML and Javascript to run the scripts back and forth. I would suggest getting a AJAX book online. Then all you would do is setup the connection and have it run a query based on the input in the textbox. So for instance, as the user types it will automatically query for things that start with each keystroke. As what they enter gets longer or more specific then so would your query.
The query might look like:
Where $textbox_input is the value the user is entering into the field being picked up by Javascript and passed on to AJAX.
The query might look like:
Code: Select all
mysql_query("SELECT title FROM articles WHERE title LIKE '%$textbox_input%'")
or die ('cannot select articles matching that description ' . mysql_error());
Re: Database Driven Autocomplete
Yeah I would be interested in a book to learn AJAX. It seems like a lot of people I talk to know of AJAX, but do not know how to code AJAX.
Interesting...
Interesting...
Re: Database Driven Autocomplete
Lol. That's because AJAX can do basically what we do right now without needing to refresh the page like in PHP. Big advantage there. In this day an age everyone wants things fast, right now, at the click of a button. AJAX does that 
I need to invest in an AJAX book myself.
I need to invest in an AJAX book myself.
- Christopher
- Site Administrator
- Posts: 13596
- Joined: Wed Aug 25, 2004 7:54 pm
- Location: New York, NY, US
Re: Database Driven Autocomplete
"Ajax" calls are normal GET or POST calls. The difference is that they are done using the Javascript XMLHTTPRequest function rather than by having a link clicked or a form submitted. The result is that you can make calls to a URL and get resposne data, without having to reload the page. There is a huge amount of information on the web about it.icesolid wrote:Im curious on how to do the AJAX auto complete.
(#10850)
- Kieran Huggins
- DevNet Master
- Posts: 3635
- Joined: Wed Dec 06, 2006 4:14 pm
- Location: Toronto, Canada
- Contact:
Re: Database Driven Autocomplete
in my pre-jQuery days I built a simple inline autocomplete method, but I would strongly encourage you to check out one of jQuery's many plugins for this behaviour.