jim.shamlin.com

Hidden Input

Hidden input fields are used to pass data to the server in a manner that is not visible to the user. It seems fairly boring and virtually useless, but there's a great deal of potential in the ability to manipulate the value of a hidden input using JavaScript.


Basics

A hidden input field is coded thus:

<INPUT TYPE="hidden" NAME="name" VALUE="value">

There is nothing displayed in the browser.


Usage

Use a hidden input field when you need to pass data to the server that the user should not be able to view or directly alter.


Processing

The value of a hidden field is passed to the server as a name-value pair, with the value reflecting the content of the VALUE attribute.


HTML Attributes

There are no other HTML attributes for a hidden field - name, type, and value are all..


JavaScript

Aside of the properies common to all form elements, the hidden input field has no unique propeties of its own.


Misc Notes

Use hidden input fields sparingly. If a server-side program needs literal values, it's probably better to code them into the script rather than passing them via a hidden input field. Said another way: there should be a compelling reason for using a hidden input field - it should not be your first choice.

Do not assume that the "invisibility" of data in a hidden fields makes it secure - a user may view it by opening the document source.

Hidden fields are often used to pass sensitive data to the server, such as the e-mail address of a recipient, a path to a data file, or a configuration variable for a server-side process. This, too, presumes a level of security that is not afforded by mere "invisibility" in the browser.