2
CS 4390 Web Programming JavaScript 7
Checkboxes
• A checkbox displays a box that can be checked or
unchecked.
• The CHECKBOX type to the INPUT tag is used to
create a checkbox, as follows:
<INPUT TYPE="CHECKBOX" NAME="choice1" VALUE="Yes" CHECKED>
– VALUE attribute assigns a meaning to the checkbox;
this is a value that is returned if the box is checked. The
default value is "on."
– CHECKED attribute can be included to make the box
checked by default.
CS 4390 Web Programming JavaScript 8
Radio Buttons
• A radio button, using the <INPUT> tag's RADIO
type.
• These buttons are similar to checkboxes, but they
exist in groups, and only one button can be
checked in each group.
• These are used for a multiple-choice or "one of
many" input.
<INPUT TYPE="RADIO" NAME="radio1" VALUE="Option1" CHECKED> Option 1
<INPUT TYPE="RADIO" NAME="radio1" VALUE="Option2"> Option 2
<INPUT TYPE="RADIO" NAME="radio1" VALUE="Option3"> Option 3
CS 4390 Web Programming JavaScript 9
Radio Buttons
• NAME attribute is used to name the entire
group of radio buttons.
• All the buttons with the same name are
considered to be in a group.
• VALUE attribute gives each button a name;
this is essential so that you can tell which
one is pressed.
CS 4390 Web Programming JavaScript 10
Selection Lists
• A selection list <SELECT> is HTML tag is used
to define a selection list, or a multiple-choice list
of text items.
<SELECT NAME="selectionList" SIZE=40>
<OPTION VALUE="choice1" SELECTED>This is the first choice.
<OPTION VALUE="choice2">This is the second choice.
<OPTION VALUE="choice3">This is the third choice.
</SELECT>
• Each of the OPTION tags defines one of the
possible choices.
CS 4390 Web Programming JavaScript 11
Selection Lists
• The VALUE attribute is the name that is returned
to the program, and the text outside the OPTION
tag is displayed as the text of the option.
• An optional attribute to the SELECT tag,
MULTIPLE, can be specified to allow multiple
items to be selected. Browsers usually display a
single-selection SELECT as a drop-down list and a
multiple-selection list as a scrollable list.
CS 4390 Web Programming JavaScript 12
Submit and Reset Buttons
• TYPE=submit is a submit button. This button
causes the data in the form fields to be sent to the
script or program.
• TYPE=reset is a reset button. This button sets
all the form fields back to their default value, or
blank.
• TYPE=button is a generic button. This button
performs no action on its own, but you can assign
it one using JavaScript.