Prentice Hall and Sun Microsystems. Personal use only; do not redistribute.
406
Chapter 16 Using HTML Forms
Check boxes
HTML Element:
(No End Tag)
Attributes:
NAME
(required),
VALUE
,
CHECKED
,
ONCLICK
,
ONFOCUS
,
ONBLUR
This input element creates a check box whose name/value pair is transmitted
only if the check box is checked when the form is submitted. For instance,
the following code results in the check box shown in Figure 16 14.
Check here if you do not want to
get our email newsletter
Figure 16 14An HTML check box.
Note that the descriptive text associated with the check box is normal
HTML, and care should be taken to guarantee that it appears next to the
check box. Thus, the
in the preceding example ensures that the check
box isn't part of the previous paragraph.
Core Approach
Paragraphs inside a
FORM
are filled and wrapped just like regular
paragraphs. So, be sure to insert explicit HTML markup to keep input
elements with the text that describes them.
NAME
This attribute supplies the name that is sent to the server. It is required
for standard HTML check boxes but optional when used with JavaScript.
VALUE
The
VALUE
attribute is optional and defaults to
on
. Recall that the name
and value are only sent to the server if the check box is checked when
the form is submitted. For instance, in the preceding example,
noEmail=on
would be added to the data string since the box is checked,
but nothing would be added if the box was unchecked. As a result, serv
lets or CGI programs often check only for the existence of the check
box name, ignoring its value.
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