Using numeric values to select item from a dropdown box with JavaScript
- by Shyam
Hi,
I have a multitude of dropdown boxes within my webpage. One of these dropdown boxes is used for a single selected value out of a list of options.
<SELECT id="Box0" name="">
<OPTION value="0">none</OPTION>
<OPTION value="1">first</OPTION>
<OPTION value="2">second</OPTION>
</SELECT>
How can I add an event to this section, so when it is in focus, I could use numeric keys like 1,2.. to select an option instead of using the mouse or arrow keys for selecting an option? For clarification: if I press "1" on my keyboard, the selected value would become "first", with "2" the selected value becomes "second".
I choose not to use a library/framework such as JQuery/Mootools.
Thanks,