aspose file tools*
The moose likes Struts and the fly likes Can I make Select Box scroll to item when it has focus? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Can I make Select Box scroll to item when it has focus?" Watch "Can I make Select Box scroll to item when it has focus?" New topic
Author

Can I make Select Box scroll to item when it has focus?

Kim Kantola
Ranch Hand

Joined: May 17, 2001
Posts: 274
Hi All,
I have a select box which contains a long list of items. I would like to try to create the behavior that when the select box has focus, if the user types in a few letters, the box will scroll forward or back to the item that matches what was typed. For example, if the list is :

Alabama
Maine
Massachusetts


The default value for the select box seems to work like this, if I type M, the box forwards to "Maine", however, if I type M followed by A, trying to get to the Massachusetts choice, I end up in Alabama ! The select only seems to regard one typed letter at a time, so if I type M followed by A, the box goes to Maine, then Alabama.

I am guessing someone must have tried to do this because I have seen this behavior on web pages before.


Thanks if anyone has a pointer.
Merrill Higginson
Ranch Hand

Joined: Feb 15, 2005
Posts: 4864
The default behavior you're describing applies only to Microsoft Internet Explorer version 6 and below. Firefox and IE 7 already have the behavior you desire. So, the easiest way to get it would be to have all your users switch to FireFox or upgrade their IE browsers to version 7.

Since that may not be practical, you are right: there are JavaScript solutions for changing IE's beahavior for select boxes. I recall one being posted on this forum. Keep looking and you'll find it.
[ February 04, 2007: Message edited by: Merrill Higginson ]

Merrill
Consultant, Sima Solutions
Kim Kantola
Ranch Hand

Joined: May 17, 2001
Posts: 274
Thanks very much Merril, I have done quite a bit of searching and can't find it, maybe I am not using great search terms because I am not sure how to word it. I am searching using "select box javascript scroll". Any idea of a better key word to use that might make this solution pop up in the search?
Thanks.
I do wish I could get users to switch to Firefox, but no hope there for now.
Merrill Higginson
Ranch Hand

Joined: Feb 15, 2005
Posts: 4864
Here's a link that I found:

http://www.oreillynet.com/pub/a/javascript/2003/09/03/dannygoodman.html
Kim Kantola
Ranch Hand

Joined: May 17, 2001
Posts: 274
Thanks very much, this is just what I was looking for, going to give it a try now . . .

 
 
subject: Can I make Select Box scroll to item when it has focus?