Prentice Hall and Sun Microsystems. Personal use only; do not redistribute.
16.5 Check Boxes and Radio Buttons
407
CHECKED
If the
CHECKED
attribute is supplied, then the check box is initially
checked when the associated Web page is loaded. Otherwise, it is ini
tially unchecked.
ONCLICK, ONFOCUS, and ONBLUR
These attributes supply JavaScript code to be executed when the button
is clicked, receives the input focus, and loses the focus, respectively.
Radio Buttons
HTML Element:
VALUE="..." ...> (No End Tag)
Attributes:
NAME
(required),
VALUE
(required),
CHECKED
,
ONCLICK
,
ONFOCUS
,
ONBLUR
Radio buttons differ from check boxes in that only a single radio button in a
given group can be selected at any one time. You indicate a group of radio
buttons by providing all of them with the same
NAME
. Only one button in a
group can be depressed at a time; selecting a new button when one is already
selected results in the previous choice becoming deselected. The value of the
one selected is sent when the form is submitted. Although radio buttons
technically need not appear near to each other, this proximity is almost always
recommended.
An example of a radio button group follows. Because input elements are
wrapped as part of normal paragraphs, a
DL
list is used to make sure that the but
tons appear under each other in the resultant page and are indented from the
heading above them. Figure 16 15 shows the result. In this case,
credit
Card=java
would get sent as part of the
form
data when the form is submitted.
Credit Card:
Visa
Master Card
VALUE="java" CHECKED>
Java Smart Card
American Express
Discover
Second edition of this book: www.coreservlets.com; Sequel: www.moreservlets.com.
Servlet and JSP training courses by book's author: courses.coreservlets.com.
footer
Our partners:
PHP: Hypertext Preprocessor Best Web Hosting
Java Web Hosting
Jsp Web Hosting
Cheapest Web Hosting
Visionwebhosting.net Business web hosting division of Web
Design Plus. All rights reserved