HTML and CSS Reference
In-Depth Information
You'll add a form element to the survey page within the main section of the page.
To add the form element:
1. Return to the survey.htm file in your text editor. Directly above the closing
</section> tag, insert the following form element as shown in Figure 6-4:
<form id=”survey” name=”survey”>
</form>
figure 6-4
inserting a form element
id and name of form
2. Save your changes to the file.
Interacting with a Web Server
Another set of form attributes specifies where to send the form data and how to send it.
You indicate this information by adding the action, method , and enctype attributes to
the form element, as follows
<form action=” url ” method=” type ” enctype=” type ”> ... </form>
where url specifies the filename and location of the program that processes the form,
the method attribute specifies how Web browsers should send data to the server, and the
enctype attribute specifies the format of the data stored in the fields.
The method attribute has two possible values: get and post . The get method , the
default, appends the form data to the end of the URL specified in the action attribute.
The post method , on the other hand, sends form data in a separate data stream. Each
method has its uses. Web searches often use the get method because the search param-
eters become part of the URL and thus can be bookmarked for future searching using the
same parameters. However, this also can result in a long and cumbersome URL if several
fields and field values are attached to the URL, and it may even result in data being
truncated if the URL text string becomes too long. There is also a security risk in hav-
ing name/value pairs attached to a URL that easily can be read by others. Your Web site
administrator can supply the necessary information about which of the two methods you
should use when accessing the scripts running on its server.
The enctype attribute determines how the form data should be encoded as it is sent
to the server. Figure 6-5 describes the three most common encoding types.
Search WWH ::




Custom Search