Section 9.1. Form Fundamentals


9.1. Form Fundamentals

Forms are composed of one or more text-input boxes, clickable buttons , multiple-choice checkboxes, and even pull-down menus and image maps, all placed inside the <form> tag. You can have more than one form in a document, and within each one you also may put regular body content, including text and images. The text is particularly useful for providing form element labels, prompts, and instructions to the users on how to fill out the form. And, within the various form elements, you can use JavaScript event handlers for a variety of effects, such as testing and verifying form contents and calculating a running sum.

A user fills out the various fields in the form, then clicks a special Submit button (or, sometimes, presses the Enter key) to submit the form to a server. The browser packages up the user-supplied values and choices and sends them to a server or to an email address. [*] The server passes the information along to a supporting program or application that processes the information and creates a reply, usually in HTML. The reply simply may be a thank you, or it might prompt the user on how to fill out the form correctly or to supply missing fields. The server sends the reply to the browser client, which then presents it to the user. With emailed forms, the information is simply put into someone's mailbox; there is no notification of the form being sent.

[*] The popular browsers may also encrypt the information, securing it from credit card thieves , for example. However, the encryption facility must be supported on the server as well: consult the web server documentation for details.

The server-side, data-processing aspects of forms are not part of the HTML or XHTML standard; they are defined by the server's software. While a complete discussion of server-side forms programming is beyond the scope of this book, we'd be remiss if we did not include at least a simple example to get you started. To that purpose, we've included at the end of this chapter a few skeletal programs that illustrate some of the common styles of server-side forms programming.

A final caveat: as is its wont, the World Wide Web Consortium (W3C) has been working on an XML-based definition of forms. This new version of forms, known as XForms, is currently a "working document," subject to review and changes as needed. XForms differs from the conventional forms model in almost every way: the forms are defined differently, data is validated differently, and information is transmitted to the server differently. As you might imagine, XForms is not currently supported by any browser or server, although a preliminary version of XForms is available for testing as part of the Mozilla XForms Project. Given its lack of general support, dramatic differences from the current model, and the long odds that XForms will replace the millions of forms already in use, it would be premature to address it in any detail in this chapter. Instead, we'll cover the forms as defined in HTML and XHTML, and leave you with a warning that a new forms model may be coming at some point in the future.



HTML & XHTML(c) The definitive guide
Data Networks: Routing, Security, and Performance Optimization
ISBN: 596527322
EAN: 2147483647
Year: 2004
Pages: 189
Authors: Tony Kenyon

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net