The SitePoint Forums have moved.

You can now find them here.
This forum is now closed to new posts, but you can browse existing content.
You can find out more information about the move and how to open a new account (if necessary) here.
If you get stuck you can get support by emailing forums@sitepoint.com

If this is your first visit, be sure to
check out the FAQ by clicking the
link above. You may have to register
before you can post: click the register link above to proceed. To start viewing messages,
select the forum that you want to visit from the selection below.

Very Very nearly working <SELECT> Searcher!!!

Well, I've just about got my facility to have a fully searchable <SELECT> list working.

Firstly, thanks to everyone who has answered various questions I've had along the way. My solution may not be elegant, but it works (well 99%) so if anyone else wants to steal it, feel free! Also, if anyone can suggest any optimisation, I'm more than happy to get it more efficiant!

All you have to do is to put a link next to a <SELECT> on you page which runs this function and pass the ID of the <SELECT> to it. A popup will appear to help you search. The popup has two fields, the top is a text box into which you type your search, the bottom is a list of found items. This begins by being full of all the values in your <SELECT> but as you type in the text box, the list is narrowed down to only those elements containing the string. If you double-click on an item in the list, the popup closes itself and the current item in the <SELECT> is changed to the chosen element.

Ok, so far so good. The problems / issues etc which would give me the extra 1% are:-

How can I modify the searchSelect() function so that while it is running, the mouse cursor changes to the hourglass and further input is disabled?

Can I speed it up in any way? I tried not dynamically creating the array and accessing the <SELECT>'s options list in real-time, but this proved to be MUCH slower. Trouble is, with some of my lists running to 700+ items, the popup can take a few seconds to appear!

Currently, the user can click outside the popup window and in effect hide it. I'd like to either force the popup to stay on top, or detect when it has been backgrounded and close it. The issue is that my users can navigate away from the calling page which makes the popup invalid!

If 3 isn't possible, is there any way I can prevent two instances running? The other problem I have is that users open the search box, accidentally return to the calling window and the try to get back to the search box by re-clicking on the search link. This causes all the code to be re-written to the same window and then, of course, it fails.