Solved

Autofill Form Fields

Posted on 2006-06-19
2
283 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
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

Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

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…
The viewer will learn how to count occurrences of each item in an array.
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

828 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