Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Tricky Drop-down

Status
Not open for further replies.

disord3r

Programmer
Apr 12, 2002
189
US
For a drop-down box, as long as it has focus, you can type in the first letter of an item you want to skip to. If there are multiple items in the drop-down box that start with that same letter, repeatedly pressing the letter will cycle you through all those items.

Now, I wonder if it would be possible to take the same idea a little further and use multiple letters to further narrow down the 'search'. For instance, if I had a drop-down box with the following items...

apple
peach

...I would want to set it up so that pressing "ap" would give you "apple", rather than "peach". Basically, I want it to capture keystrokes until no more keys are pressed within a certain amount of time, and then go and select the item whose leftmost X number of letters match whatever had been typed. In the case of multiple matches, it should still take you to the first match.

Would that be possible at all?
 

Everything is possible -- it just depends how much time and effort (and $$$) you want to put into something that is not natively supported in a web page control.

The drop downs in web pages are different than in other GUI applications. The dropdowns in regular EXEs are actually comboboxes, not dropdowns.

Since you are not actually typing anything in the dropdown (it is just reading the letter you pressed and finding the next item starting with it), you would have to use a key capturing script that resets anytime the focus is removed from that object.

Chances are this will only work in MSIE and the NN6+ browsers too, since NN4.5 cannot read actual selected values, just positions.

If you only want it to work in MSIE, you could probably use the actual combobox activex object, but you would have to code responses in VBScript. In this case it would natively use the "abc" selection method you want, but NN users would not even see that field.


Glen Palmer
SafariTECH
"because it's a jungle out there"
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top