How to autopopulate
Moderator: General Moderators
-
- Forum Newbie
- Posts: 1
- Joined: Sat Sep 10, 2016 5:29 am
How to autopopulate
How can I autopopulate things in dropdown like I want that if I type 'a' every thing starting with 'a' should apppear?
Re: How to autopopulate
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.
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.