Understanding XForms, cont.
This chapter is a primer on XForms; however, it's important that
you understand and are able to use current form applications. Table
8.1 lists all XHTML elements and attributes used to create forms. For
detailed descriptions of these elements and attributes, see Chapter
3, "Overview of Element Structure."
Table 8.1 XHTML Form Elements and Attributes
| Element Name |
Empty |
Description |
Possible Attributes |
|
button |
No |
Creates an input
button |
disabled, name, tabindex, type, value |
|
fieldset |
No |
Groups related form controls |
None |
|
form |
No |
Contains form
block |
accept, accept-charset, action, enctype, method |
|
input |
Yes |
Defines type and appearance
for input objects |
accept, align*, alt, checked, disabled, maxlength,
name, readonly, size, src, tabindex, type, usemap, value |
|
isindex |
Yes |
Solicits a single line of input from users |
prompt |
| label |
No |
Identifies form controls |
accesskey, for |
|
legend |
No |
Provides a caption to a set of
related form controls |
align*,
accesskey_ |
| option |
No |
Assigns a value to an input label |
disabled, selected, value |
| optgroup |
No |
Groups selection choices logically |
disabled, label |
| select |
No |
Creates a menu of scrolling list of input items |
disabled, multiple, name, size, tabindex |
| textarea |
No |
Multiple line text area |
accesskey, cols, disabled, name, readonly, rows, tabindex |
*Denotes a deprecated attribute
Example 8.1 A Simple XHTML Form Enables Customer
Data to Be Sent to a Server
<?xml version="1.0"?>
<!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0
Transitional//EN"
"DTD/xhtml1-transitional.dtd">
<html>
<head>
<title>Title of the document.
</title>
</head>
<body>
<form action="URL" method="post">
<p>This is a simple form.
</p>
<fieldset>
<legend>Customer
Information</legend><br />
Last Name: <input
name="lastname" type="text" tabindex="1"
/><br />
First Name: <input
name="firstname" type="text" tabindex="2"
/><br />
E-mail Address:
<input name="address" type="text" tabindex="3"
/>
</fieldset>
</form>
</body>
</html>
The input elements collect data-in text form-from the user. That
data is then instructed by the form element to be passed to a Uniform
Resource Locator (URL) to be processed. That URL points to a server
application ready to process the data. It's as easy as that.
To see how this example renders in a browser, see Figure 8.3.
Figure 8.3 A simple form displayed in a browser.
(NOTE: This image is only available in the book, not in
this article)
|