Win a copy of Learn Spring Security (video course) this week in the Spring forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Choose drop down list option with more than one character?

 
seb petterson
Ranch Hand
Posts: 118
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 118
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ok, I solved it with the setTimeOut function:

 
seb petterson
Ranch Hand
Posts: 118
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic