HTML and CSS Reference
In-Depth Information
Hidden Form Fields
Hidden form fields are used when you want to embed data in a page that shouldn't be
seen or modified by the user. The name and value pair associated with a hidden form
field will be submitted along with the rest of the contents of the form when the form is
submitted. To create such a field, set the field's type to hidden and be sure to include
both the name and value attributes in your <input> tag. Here's an example:
<input type=“hidden” name=“id” value=“1402” />
Hidden form fields are generally used when data identifying the user needs to be
included in a form. For example, suppose you've created a form that allows a user to edit
the name and address associated with her bank account. Because the user can change her
name and address, the data she submits can't be used to look up her account after she
submits the form, plus there might be multiple accounts associated with one name and
address. You can include the account number as a hidden field on the form so that the
program on the server knows which account to update when the form is submitted.
It's important to understand that when it comes to hidden form
fields, hidden means “won't clutter up the page” rather than
“won't be discoverable by the user.” Anyone can use the View
Source feature in the browser to look at the values in hidden form
fields, and if you use the GET method, those values will appear in
the URL when the form is submitted, too. Don't think of hidden
fields as a security feature but rather as a convenient way to
embed extra data in the form that you know the script that
processes the form input will need to use.
The File Upload Control
The file control enables a user to upload a file when he submits the form. As you can see
in the following code, the type for the input element is set to file :
<label> Please select a file for upload <input type=“file” name=“fileupload”
Figure 11.11 shows a file upload control.
Search WWH ::

Custom Search