aspose file tools*
The moose likes HTML, CSS and JavaScript and the fly likes Choose drop down list option with more than one character? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "Choose drop down list option with more than one character?" Watch "Choose drop down list option with more than one character?" New topic
Author

Choose drop down list option with more than one character?

seb petterson
Ranch Hand

Joined: Mar 04, 2005
Posts: 118
My users requests to be able to choose an option from a drop down list by typing in several characters of the text of the option, this is necessary since several options starts with the same characater and they need to be able to do it quickly.

I am attaching the code below that I have tried with. The problem I get is that the browser seems to override my javascript on the change of selected option. That is: if there are the options "one", "two", "onetwo".. I have done it so that when the word starting with "onet" has been entered i select the option with text "onetwo" but as soon as the function exists, the browser switches the selected option to "two" since the last key i pressed was a "t". I have allready tried the e.stopPropagation()
and window.event.cancelBubble = true

I need only my code to work in Internet Explorer (it's on an intranet).




(Please replace "on_KeyDown" with "onKeyDown", it didnt let me post this word.)

[ May 30, 2006: Message edited by: seb petterson ]

[ May 30, 2006: Message edited by: seb petterson ]
[ May 30, 2006: Message edited by: Bear Bibeault ]
seb petterson
Ranch Hand

Joined: Mar 04, 2005
Posts: 118
Ok, I solved it with the setTimeOut function:

seb petterson
Ranch Hand

Joined: Mar 04, 2005
Posts: 118
I just discovered that the setTimeOut() solution was a bit overkill. All I needed was to add "return false;" to the value of the onKeyDown attribute of the select element.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Choose drop down list option with more than one character?