Solved

Autofill Form Fields

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

SharePoint Admin?

Enable Your Employees To Focus On The Core With Intuitive Onscreen Guidance That is With You At The Moment of Need.

Question has a verified solution.

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

Suggested Solutions

Popularity Can Be Measured Sometimes we deal with questions of popularity, and we need a way to collect opinions from our clients.  This article shows a simple teaching example of how we might elect a favorite color by letting our clients vote for …
This article discusses how to create an extensible mechanism for linked drop downs.
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…
The viewer will learn how to dynamically set the form action using jQuery.

751 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