all
alt
ch
dir
id
min
rel
top
url
URL
urn
Expand Minimize

checked attribute | checked property

Sets or retrieves the state of the check box or radio button.

HTML 4.01 Specification, Section 17.4

Syntax

HTML<element checked="p" ... >
JavaScript

p = object.checked

Property values

Type: Boolean

false

Default. Control is not selected.

true

Control is selected.

Standards information

Remarks

Check boxes that are not selected do not return their values when the form is submitted.

A user can select a radio button only if the button has a name. To clear a selected radio button, a user must select another button in the set.

Examples

This example retrieves the checked property to fire an event.


<head>
    <script type="text/javascript">
    function checkthis()
    {
        if (oCheckbox.checked == true)
        {
            window.open("http://www.microsoft.com");
        }
    }
    </script>
</head>
<body>
    <p>Check here if you wish to go to Microsoft:
    <input id="oCheckbox" type="checkbox" onclick="checkthis()"></p>
</body>

See also

input
input type=checkbox
input type=radio
Reference
defaultChecked
Conceptual
Introduction to Forms
Form controls part 1
Form controls part 2: validation

 

 

Show:
© 2014 Microsoft