Reputation: 43959
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.
Upvotes: 2
Views: 13490
Reputation: 9389
You have the onkeydown event. MSDN
In your case, onchange will be raised when the select list loses the focus.
Upvotes: 1
Reputation: 2521
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>
Upvotes: 4