CHECKED Attribute | checked Property

DHTML, HTML, & CSS

CHECKED Attribute | checked Property


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

Syntax

HTML<ELEMENT CHECKED = bChecked ... >
Scriptinginput.checked [ = bChecked ]

Possible Values

bChecked Boolean that specifies one of the following values:
falseControl is not selected.
trueControl is selected.

The property is read/write with a default value of false.

Expressions can be used in place of the preceding value(s), as of Microsoft® Internet Explorer 5. For more information, see dynamic propertiesInternet Link.

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.

Example

This example retrieves the checked property to fire an event.

Sample Code

<HEAD>
<SCRIPT>
function checkthis()
{
    if (oCheckbox.checked == true)
    {
        alert("It's got a check; now off to Microsoft!");
        window.open("http://www.microsoft.com");
    }
}
</SCRIPT> 
</HEAD>
<BODY>
Check here if you wish to go to Microsoft:
<INPUT ID=oCheckbox TYPE=checkbox onclick=checkthis()>
</BODY>

This feature requires Internet Explorer 4.0 or later. Click the icon below to install the latest version. Then reload this page to view the sample.
Microsoft Internet Explorer

Applies To

[ Object Name ]
PlatformVersion
Win16:
Win32:
Mac:
Unix:
WinCE:
Version data is listed when the mouse hovers over a link, or the link has focus.
INPUT TYPE=checkbox, INPUT TYPE=radio

See Also

defaultChecked, forms overviewInternet Link

Back to topBack to top

Did you find this topic useful? Suggestions for other topics? write us!Internet Link

© 1999 microsoft corporation. all rights reserved. terms of useInternet Link.