Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

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

 
Kim Kantola
Ranch Hand
Posts: 276
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 4864
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 ]
 
Kim Kantola
Ranch Hand
Posts: 276
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 4864
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Here's a link that I found:

http://www.oreillynet.com/pub/a/javascript/2003/09/03/dannygoodman.html
 
Kim Kantola
Ranch Hand
Posts: 276
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks very much, this is just what I was looking for, going to give it a try now . . .

 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic