Solved

Autofill Form Fields

Posted on 2006-06-19
2
286 Views
Last Modified: 2008-03-17
Hi!

I'd like to be able to query a database, and while typing characters into a form field, have this field auto-filled with relevant data from the database.

For example:

When I start typing "Jo", it should fill in "John Doe" or when I type "Joe", it should fill in "Joe Bloggs", etc.

I believe this can be done using AJAX, but don't know a lot about it... Would be gratefull if someone could point me in the right direction...
0
Comment
Question by:Julian Matz
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 15

Accepted Solution

by:
babuno5 earned 300 total points
ID: 16935868
0
 
LVL 7

Assisted Solution

by:maUru
maUru earned 200 total points
ID: 16975639
http://gadgetopia.com/autosuggest

thats the code, shamelessly stolen from gadgetopia :)

and of course to populate the arrays just use:

<script language="Javascript">
    var states = newArray(
<?
$q = "SELECT Name FROM table";
$r = mysql_query($q);
$i = 0;
$n = mysql_num_rows($r);
while ($row = mysql_fetch_assoc($r) {
    echo '"' . $row['Name'] . '"';
    if ($i != $n - 1) { echo . ",\n"; }
}
);
?>
    new AutoSuggest(document.getElementById('state'),states);
</script>
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Developers of all skill levels should learn to use current best practices when developing websites. However many developers, new and old, fall into the trap of using deprecated features because this is what so many tutorials and books tell them to u…
Password hashing is better than message digests or encryption, and you should be using it instead of message digests or encryption.  Find out why and how in this article, which supplements the original article on PHP Client Registration, Login, Logo…
The viewer will learn how to count occurrences of each item in an array.
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

615 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