home | O'Reilly's CD bookshelfs | FreeBSD | Linux | Cisco | Cisco Exam  


JavaScript: The Definitive Guide

Previous Chapter 21
JavaScript Reference
Next
 

Radio.defaultChecked Property

Name

Radio.defaultChecked Property---initial state of a Radio button

Availability

Navigator 2.0, Internet Explorer 3.0

Synopsis

radio.defaultChecked

Description

defaultChecked is a read-only Boolean property of the Radio object. It is true if the Radio button is initially selected--i.e., if the CHECKED attribute appears in the Radio's HTML <INPUT> tag. If this tag does not appear, then the Radio button is initially deselected, and defaultChecked is false.

Usage

You can use the defaultChecked property to reset a group of radio buttons back to its default state. You might do this when the user selects a Reset button in a form, for example. You can reset a group of radio buttons with the following function:

function resetRadio(radio_group) {
    var i;
    for(i = 0; i < radio_group.length; i++) {
        if (radio_group[i].defaultChecked) {
            radio_group[i].checked = true;
            break;
        }
    }
}


Previous Home Next
Radio.click() Book Index Radio.focus()

HTML: The Definitive Guide CGI Programming JavaScript: The Definitive Guide Programming Perl WebMaster in a Nutshell