Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Autofill Form Fields

Posted on 2006-06-19
2
Medium Priority
?
293 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 1200 total points
ID: 16935868
0
 
LVL 7

Assisted Solution

by:maUru
maUru earned 800 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

Independent Software Vendors: 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

Foreword (July, 2015) Since I first wrote this article, years ago, a great many more people have begun using the internet.  They are coming online from every part of the globe, learning, reading, shopping and spending money at an ever-increasing ra…
These days socially coordinated efforts have turned into a critical requirement for enterprises.
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…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
Suggested Courses

916 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