| input (type="radio") | NN 2 IE 3 DOM 1 |
|
| |
|
The radio object is a form control generated with
an input element that has a
type attribute set to "radio".
radio objects related to each other are assigned
the same name. This means all like-named radio
objects become a collection (array) of radio objects. It may be
necessary, therefore, to reference an individual radio button as an
item in an array. The entire array, of course, has a
length property you can use to assist in looping
through all radio objects within the group, if
necessary, to find which one is checked, and retrieve that
object's value:
var radioGrp = document.forms[0].myRadio;
for (var i = 0; i< radioGrp.length; i++) {
if (radioGrp[i].checked) {
alert("The value of the chosen button is " + radioGrp [i].value);
}
}
|
| |
Properties and methods listed as follows are for individual radio
buttons.
|
| |
| HTML Equivalent |
| |
<input type="radio">
|
| |
| Object Model Reference |
| |
[window.]document.formName.elementName
[window.]document.forms[i].elements[i]
[window.]document.getElementById("elementID")
|
| |
| Object-Specific Properties |
| |
| checked | dataFld | dataSrc | defaultChecked | form |
| name | status | type | value | |
|
| |
| Object-Specific Methods |
| |
|
|
| |
| Object-Specific Event Handler Properties |
| |
| Handler | NN | IE | DOM | | onblur | 6 | 4 | 2 |
| onclick | 3 | 4 | 2 |
| onfocus | 6 | 4 | 2 |
| onmousedown | 4 | 4 | 2 |
| onmousemove | 6 | 4 | 2 |
| onmouseout | 6 | 4 | 2 |
| onmouseover | 6 | 4 | 2 |
| onmouseup | 4 | 4 | 2 |
|