How to autopopulate

Ye' old general discussion board. Basically, for everything that isn't covered elsewhere. Come here to shoot the breeze, shoot your mouth off, or whatever suits your fancy.
This forum is not for asking programming related questions.

Moderator: General Moderators

Post Reply
Forum Newbie
Posts: 1
Joined: Sat Sep 10, 2016 5:29 am

How to autopopulate

Post by priyamsharma474 »

How can I autopopulate things in dropdown like I want that if I type 'a' every thing starting with 'a' should apppear?
User avatar
Spammer :|
Posts: 6617
Joined: Wed Oct 15, 2008 2:35 am
Location: WA, USA

Re: How to autopopulate

Post by requinix »

If it's a short list of items then HTML 5 has datalists: you put the list into the HTML and let the browser do the rest.

If it's a long list, like if you need to search your database, then the answer is AJAX: do a request when the user types to a PHP script, which includes what the user has typed, it does the database query or whatever to get the results, and they are returned to the Javascript code which displays the results. Using a library or plugin makes all that much easier - all you need to do is write the PHP code.
Post Reply