Next / Previous / Contents / TCC Help System / NM Tech homepage

6. Radiobuttons

Radiobuttons are used in groups of two or more to allow the user to select one of a set of mutually exclusive choices. Setting one radiobutton in a group automatically clears the others in the group.

The radiobuttons in a group are defined separately, one per input tag. All radiobuttons in a group must, however, have the same name="fieldName" value.

<input type="radio" name="fieldName" value="choiceText" checked>

where:

fieldName

is an internal name that will be passed to the downstream CGI script as the name of this element. All radiobuttons in the same group must have the same value for this attribute.

choiceText

will be passed to the downstream CGI script as the value of this field, if this particular radiobutton is selected.

checked

is optional; specify this attribute in the radiobutton that you want to be set (on) when the form is initially displayed.

Note

If none of the radiobuttons in a group have the checked attribute, none of the radiobuttons will be set initially. If the user of the form doesn't then select any of them, the downstream CGI script will not receive a (name,value) pair for that group. To avoid this situation, always specify one of the radiobuttons as checked; once one of the radiobuttons has been set in a form, there is no way for the user to clear them all.