HTML and CSS Reference
In-Depth Information
name. he value that a checkbox has when the form is submitted is given by
the input element's value attribute. It defaults to “on” if checked and the value
attribute is missing. Only elements that the user checks are sent to the server
as a name=value pair upon form submission. Before the form is submitted,
all checkboxes have a value whether they are checked or not. If a client-side
script needs to examine the value of a checkbox, it must also test that element's
checked property.
An input element with a type attribute value of hidden creates an element
that is inaccessible to the user. Its purpose is to provide a data value in the
form of a name=value pair to the CGI script receiving the input or a client side
script handling page events. Hidden ields can provide coniguration infor-
mation or identify the page submitting the form. Example 2.26, shown in a
moment, uses hidden ields.
One additional input element is worth mentioning. If the type attribute has
the value "ile" , the browser presents both an input text ield and a Browse but-
ton for the purpose of selecting a ile to upload from the user's local PC. For
this to work correctly, the form element must have its method set to post and
the attribute enctype set to "multipart/form-data" . Because this changes how
the form's input is sent to the server, check with your webmaster before writing
code that uploads iles.
For multiline text input in a form, a textarea is used. Unlike the input ele-
ment, the textarea element is a block element and a container. A textarea
element is usually written with rows and cols attributes to set the initial size
of the input area. he content, which is treated like text without markup in a
preformatted element, is its initial value.
Example 2.26 includes all the form elements discussed so far. For the action
attribute, the URL of a form-to-email script is used. he script accepts input
from hidden values to set the subject and recipient of the email message it
will send from the server. Furthermore, it recognizes certain input names. In
particular, by using "fullname" and "email" for the names of the input ields
for that information, the script uses the values of those ields to construct the
message's From address, such as "Betty Boop" <>.
Example 2.26: An input form that calls a form-to-email Cgi script
<!DOCTYPE html>
<head><title>Example 2.26</title></head>
Search WWH ::

Custom Search