How to find the select box option in javascript?
or
What are the events associated with SelectBox?
Event Handler | Description | Example |
onMouseOver | onMouseOver is invoked when a mouse is moved over the Select Box | Result : |
onMouseDown | onMouseDown is invoked when a mouse is pressed down on the Select Option | Result : |
onMouseUp | onMouseUp is invoked when a mouse is pressed down on the select option and released | Result : |
onChange | onChange is invoked when a new option is selected | Result : |
onBlur | onBlur Executes some code when the SelectBox loses focus using tab | Result : |
onFocus | onFocus Executes some code when the SelectBox gets the focus using tab | Result : |
DOM Property | Description | Example |
length | Used to get the length (total number of options) in the select object | To Get: var len = document.tests.sel.length; |
name | Used to get Select Box name | To Get: var ss = document.tests.sel.name; |
options | Returns the array of options listed in the select object | To Get: var ss = document.tests.sel.options; |
selectedIndex | selectedIndex is used to get or set the position of the option selected | To Get: var ss = document.tests.sel.selectedIndex; Returns 1 if the second option is the selected one. To Set: document.tests.sel.selectedIndex = 0; |
text | Returns the text value present in the select box | To Get: var dd = document.tests.sel.selectedIndex; var ss = document.tests.sel[dd].text; |
DOM Method | Description | Example |
blur() | Used to dynamically make the Radio Button blur | To Blur: document.testb.mycb.blur(); |
focus() | Used to dynamically get focus on the Radio Button | To Focus: document.testb.mycb.focus(); |