HTML and CSS Reference
In-Depth Information
Table 9.1 <form> tag attributes
Attribute
Values
Purpose
When used to invoke server-side processing, the
value should be a valid file name on a Web server.
This is often a PHP script (.php extension), a
Microsoft Active Server Pages (.asp extension), or a
Sun JavaServer Pages (.jsp extension) file.
When used to send an e-mail, the value should
be mailto: followed by a valid e-mail address.
This attribute is optional. It is commonly used
to specify what server-side program or script
will process your form data using CGI.
Although not recommended, this attribute
can also be used to specify an e-mail address
that the form information will be sent to.
If no action attribute is present, the
Web page containing the form is requested
and redisplayed by the browser.
action
Alphanumeric, no spaces. The value must be
unique and not used for other id values on the
same XHTML document.
This attribute is optional. It provides a unique
identifier for the form.
id
This attribute is optional, but defaults to a
value of get if omitted. The value of get
causes the form data to be appended to the
URL and sent to the Web server.
method
get
The post method is more private and trans-
mits the form data in the body of the HTTP
response. This method is preferred by the
W3C.
post
Alphanumeric, no spaces, begins with a letter.
Choose a form name value that is descriptive but
short. For example, OrderForm is better than Form1
or WidgetsRUsOrderForm.
This attribute is optional. It names the form
so that it can be easily accessed by client-
side scripting languages, such as JavaScript,
to edit and verify the form information before
the server-side processing is invoked.
name
FAQ
How can I send form information in an e-mail?
Forms usually need to invoke some type of server-side processing to perform functions such as
sending e-mail, writing to text files, updating databases, and so on. Another option is to set up
a form to send information using the e-mail program configured to work with the Web page vis-
itor's browser. In what is sometimes called using a mailto: URL, the <form> tag is coded to
use your e-mail address in the action attribute:
<form method="post" action="mailto:lsnblf@yahoo.com">
When a form is used in this manner the Web visitor will see a warning message. The warning
message presents a nonprofessional image and is not the best way to inspire trust and confi-
dence in your Web site or business.
Be aware that information sent in e-mail messages is not secure. Sensitive information, such as
credit card numbers, should not be transmitted using e-mail. See Chapter 12 for information
about using encryption to transmit data securely.
There are other reasons not to use the mailto: URL. For example, when people share a computer
—they may not be using the default e-mail application. In this case, filling out the form is a
waste of time. Even if the person using the computer also uses the default e-mail application,
 
Search WWH ::




Custom Search