views:

251

answers:

2

I have a dropdown list. I am using onchange event of this dropdown to show some text in a textbox below. Its perfectly fine. But i want to to do something like this:---

If user click on the drop down then the whole list will be populated. right.. Now if he is trying to choose the value from the list using up/down arrow button of the key board i want to fire the event at that time. How can i do this.

           Onchange  is not working for this purpose.
+1  A: 

You have the onkeydown event.MSDN

In your case,onchange will be raised when the select list loose the focus.

remi bourgarel
+1  A: 

You can do something like this:

<script type="text/javascript">
   function change(value){
      alert("key pressed "+value)
   }    
</script>

<select name="k" onkeypress="change(this.value)">
    <option value="acb">ABC</option>
    <option value="def">DEF</option>
</select>
Lex