views:

30

answers:

3

My employer has asked me how to mix the functionality of a textfield input with a select input, "kinda like gmail does when you start typing the address of someone you've already written to, it allows you to choose the person and also to keep writing if it isn't in the database".

How is this done? I imagine there's a javascript/jquery library to implement this.

+1  A: 

It's called autosuggest or autocomplete. As you're typing, the value of the input is sent via ajax to a server side script (php, for example), which searches a database for a matching item. It then returns the items, and jquery displays them under the input.

There are a bunch of example / tutorials. I'll try to find a good one.

hookedonwinter
+1  A: 

Yes, there's a whole lot of such plugins. These are probably two most popular (most often asked on SO) and customizable:
http://bassistance.de/jquery-plugins/jquery-plugin-autocomplete/ (demo here)
http://jqueryui.com/demos/autocomplete

Nikita Rybak
+1  A: 

The keyword you are searching for is "autocomplete". There are many jQuery plugins to do that.

Here is one: http://www.pengoworks.com/workshop/jquery/autocomplete.htm

Raphael Jolivet