Solved

Autofill Form Fields

Posted on 2006-06-19
2
279 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
2 Comments
 
LVL 15

Accepted Solution

by:
babuno5 earned 300 total points
Comment Utility
0
 
LVL 7

Assisted Solution

by:maUru
maUru earned 200 total points
Comment Utility
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

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

Things That Drive Us Nuts Have you noticed the use of the reCaptcha feature at EE and other web sites?  It wants you to read and retype something that looks like this.Insanity!  It's not EE's fault - that's just the way reCaptcha works.  But it is …
This article discusses four methods for overlaying images in a container on a web page
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
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.

744 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

18 Experts available now in Live!

Get 1:1 Help Now