How to populate related data in top of select box?

Hi all,
In my form,I want to put one select box to select users…
Now in my database table user_table contains more than 1000 records…
But i don’t want to waste the time to select appropriate user from select box…
Thats why i put one text box on the top of the select box, if i type any character in it,the select box will shows the related records on top of the select box of that character…
If i type two char’s, it is again will show the much related on the top of the select box…

How can i implement it in my form…
Give me any suggestions/guidelines…

Thanking you…

Search for “php autocomplete”. :wink:

Thank you for replying me…
Is there any site for explaining this topic with an example…
Please provide the URL…

javascript

One option is to use AJAX.

Whenever the text in the text box changes, send an AJAX request to the server to get all the usernames that contain the string in the textbox.

Then you can use DOM methods to delete the current options in the select and replace them with new options using the returned usernames from the ajax request.

That’s true. You could also load all necessary data at first call (eliminating the need for calls to the server), but it this case it might be a bit too much, so AJAX is definitely the way to go.

I don’t see how you can get the usernames from the database using javascript on its own.

You would need AJAX, which is just a particular method of using javascript, to send a request to a server side script to send back the data from the database.

You need both AJAX (javascript) and a server side script.