How to change Radio Button selection using javascript?
or
What are the events associated with Radiobutton?
Event Handler | Description | Example |
onMouseOver | This is invoked when a mouse is moved over the Radio Button | <input type=radio onMouseOver="output()"> Result : CB1 |
onMouseDown | This is invoked when a mouse is pressed down on the Radiobutton | <input type=radio onMouseDown="output()"> Result : CB1 |
onMouseUp | This is invoked when a mouse is pressed down on the radio and released | <input type=radio onMouseUp="output()"> Result : CB1 |
onClick | This is invoked when a mouse click is done on the radio | <input type=radio onClick="output()"> Result : CB1 |
onBlur | Executes some code when the Radio Button loses focus using tab | <input type=radio onBlur="output()"> Result : CB1 |
onFocus | Executes some code when the radio button gets the focus using tab | <input type=radio onFocus="output()"> Result : CB1 |
DOM Property | Description | Example |
checked | Used to check or select RadioButton selection | To Check: var ss = document.testb.myrb[0].checked; To Select: document.testb.myrb[1].checked = true; This will select second element. |
defaultChecked | Used to check whether the Radio Button is checked by default | To Get: var ss = document.testb.myrb[0].defaultChecked; |
form | Used to get the parent node (form object) of this RadioButton | To Get: var ss = document.testb.myrb[0].form; |
name | Used to get Radio Button name | To Get: var ss = document.testb.myrb[0].name; |
type | Used to get form type | To Get: var ss = document.testb.myrb[0].type; |
value | Used to set or get RadioButton value | To Get: var ss = document.testb.myrb[0].value; To Set:: document.testb.myrb[0].value = "testy"; |
DOM Method | Description | Example |
click() | Used to dynamically make a Radio Button checked | To Click: document.testb.myrb.click(); |
blur() | Used to dynamically make the Radio Button blur | To Blur: document.testb.myrb.blur(); |
focus() | Used to dynamically get focus on the Radio Button | To Focus: document.testb.myrb.focus(); |