views:

23

answers:

1

After several failed attempts using ExtJS I have now decided to use javascript.The requirement is to assist a combo box in select tag.If the list contains aa,aaa,aab,abc,bac,cba then if I type 'ab' continuously then it will select 'abc'.Whereas if I type 'a' time gap and then 'b' it will select 'bac' instead of 'abc'. Can anyone tell me whether its possible in js to get what I want?If not js is it possible in Jquery.Please ignore the previous duplicates.

A: 

It's possible. You're going to want to track when you your keypress events fire. Capture the time the "a" was entered, and then the time the second key was entered. If it's above a threshold, you want the second letter to be first, and the first letter to come second. If it's below your threshold, you want the first letter first, and the second letter second.

Jonathan Sampson
Yes exactly.How is it possible.Can you elaborate
Similar question with code-example at http://stackoverflow.com/questions/1223764
Jonathan Sampson
Do you have onkeyup for Select tag?
You will need to bind this to a textbox, and use the value of the textbox to filter the select options.
Jonathan Sampson
bind to a textbox? how is that possible?
$("textbox.myTextbox").bind("keyup", function(event){ /* code here */ }); Within your "/* code here */" portion is where you will filter the results, using the select > option's as your datasource.
Jonathan Sampson
this is Jquery right? Is binding possible in Js?
@Harish, Yes. I was using jQuery syntax. You can bind with pure JS too. You'll add event-handlers. http://www.quirksmode.org/js/introevents.html
Jonathan Sampson

related questions