HTML The Definitive Guide (101 page)

Read HTML The Definitive Guide Online

Authors: Chuck Musciano Bill Kennedy

BOOK: HTML The Definitive Guide
9.8Mb size Format: txt, pdf, ePub

The dir and lang attributes are supported by the popular browsers, even though there are no
behaviors defined for any specific language. [The dir attribute, 3.5.1.1] [The lang attribute, 3.5.1.2]

10.2.8 The Event Attributes

As for most other elements in an HTML 4.0 standard document, the

tag honors the standard mouse and keyboard event-related attributes that the HTML 4.0-compliant browser will recognize.

We describe the majority of these attributes in detail in Chapter 13, Executable Content. [JavaScript

Event Handlers, 13.3.3]

Forms have two special event-related attributes: onSubmit and onReset. The value of these event attributes is - enclosed in quotation marks - one or a sequence of semicolon-separated JavaScript expressions, methods, and function references. With onSubmit, the browser executes these commands before it actually submits the form's data to the server or sends it to an email address.

You may use the onSubmit event for a variety of effects. The most popular is for a client-side form-verification program that scans the form data and prompts the user to complete one or more missing elements. Another popular and much simpler use is to inform users when a mailto URL

form is being processed via email.

The onReset attribute is used just like the onSubmit attribute, except that the associated program code is executed only if the user presses a "Reset" button in the form.

10.1 Form Fundamentals

10.3 A Simple Form Example

Chapter 10

Forms

 

10.3 A Simple Form Example

In a moment we'll examine each of the many form controls in detail. Let's first take a quick look at a
simple example to see how forms are put together. This one (shown in Figure 10.1) gathers basic

demographic information about a user:

Name:


Sex:

Male Female


Income:





The first line of the example starts the form and indicates that we'll be using the POST method for data transmission to the form-processing server. The form's user-input controls follow, each defined by an tag and type attribute. There are three controls in the simple example, each contained within its own paragraph.

Figure 10.1: A simple form

The first control is a conventional text entry field, letting the user type up to 80 characters, but displaying only 32 of them at a time. The next one is a multiple-choice option, which lets the user select only one of two radio buttons. This is followed by a pulldown menu for choosing one of three options. The final control is a simple submission button, which, when clicked by the user, sets the form's processing in motion.

10.2 The

Tag

10.4 Using Email to Collect

Form Data

Other books

Primal by Leigh, Lora
The Billionaire's Demon by Gayle, Eliza
Reel Stuff by Don Bruns
3. A Second Chance by Jodi Taylor
Swimming by Nicola Keegan
Building From Ashes by Elizabeth Hunter
Rockstar by Lexi Adair