INPUT type=radio Element | INPUT type=radio Object

DHTML, HTML, & CSS

 
Click to return to the DHTML, HTML & CSS home page    
INPUT type=password     INPUT type=submit     DHTML Objects    

INPUT type=radio Element | INPUT type=radio Object


Creates a radio button control.

HTML Syntax

<INPUT	
    ACCESSKEY = key
    ALIGN = LEFT | CENTER | RIGHT
    ALT = text
    CHECKED
    CLASS = classname
    DISABLED
    ID = value
    LANG = language 
    LANGUAGE = JAVASCRIPT | JSCRIPT | VBSCRIPT  | VBS
    LOWSRC = url
    MAXLENGTH = n
    NAME = name
    READONLY
    SIZE = n
    STYLE = css1-properties
    TABINDEX =n
    TITLE =text
    TYPE = RADIO
    VALUE = value
    event  = script
>

Remarks

Use a radio button control to limit a user's selection to a single value within a set of values. To do this, you must link together each button in a set of radio buttons by assigning each button the same name.

When a user submits a form, a selected radio button only generates a name/value pair in the form data if the button has a value.

To select a radio button as the default button in a set, set the checked property of the button to true.

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.

The radio element is an inline element and does not require a closing tag.

This element is available in HTML and script as of Microsoft® Internet Explorer 3.0.

Members

Styles

Example

This example uses the radio element to create three radio buttons.

Sample Code

<INPUT type=radio name="radio" CHECKED>1-10 years old
<INPUT type=radio name="radio">11 years old
<INPUT type=radio name="radio">12-120 years old

This example uses script to detect which radio button the user selects.

<SCRIPT>
function detect()
{
    if (radio[0].checked)
        alert("You're between 1 and 10 years old.")
    else if (radio[1].checked)
        alert("You're 11 years old.")
    else
        alert("You're between 12 and 120 years old.")
}
</SCRIPT>

The preceding HTML code and script examples create and implement the following radio buttons.

1-10 years old

11 years old

12-120 years old

See Also

INPUT, 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.