Page 1 of 1

Auto-Populate Selection List on Search

Posted: Fri Aug 31, 2012 4:41 pm
by Skara
The Problem:
I have a long list of clients. I need to attach a main contact to each project (in a longer list of projects).

The Idea:
I need a scrolling select field that, at first, displays the most recent clients added (say 5). But when you start typing in the search box, it populates as you type with possible matches. You click on the person you want, click [Attach], and you're done.

Search Clients: [__start_typing_client_name_here__]
Select Client:
[______]
[______]
[______]
[______]
[Attach]

I'm thinking this is probably pretty easy; I'm just terrible when it comes to anything client-side. Can someone point me in the right direction?

Bonus Thought:
If I could figure out how to have the list auto-populate with more entries as you scrolled down through them, that would be awesome—particularly while it's still displaying the most recent clients.


Thanks!
—(totally lost) William

Re: Auto-Populate Selection List on Search

Posted: Fri Aug 31, 2012 5:34 pm
by Christopher
This would be done with javascript. Are you using a javascript library?

Re: Auto-Populate Selection List on Search

Posted: Fri Aug 31, 2012 6:22 pm
by Skara
I'm using jQuery for a couple of other things. I understand the syntax, I just need to know what to do with it. Hah.

Re: Auto-Populate Selection List on Search

Posted: Sat Sep 01, 2012 10:29 pm
by Christopher
You can use jQuery's .html() method to set the options in the select. The search box would make an Ajax call each time a character is typed. The Ajax call would call a PHP script that generates the <option> list base on the search string.

Or if the list is not too long, you could do the whole thing in javascript. When you generate the page you would create a javascript array of the full client list -- and then search for matches in it to create the <option> list.

Re: Auto-Populate Selection List on Search

Posted: Thu Sep 06, 2012 3:52 am
by Skara
GOT it. Problem solved.

Thanks.