HTML and CSS Reference
Another use for hidden fields is to manage user-server interactions.
For instance, it helps the server to know that the current form has
come from a person who made a similar request a few moments ago.
Normally, the server does not retain this information, and each trans-
action between the server and client is completely independent from all
For example, the first form the user submits might have asked for some
basic information, such as the user's name and where she lives. Based
on that initial contact, the server might create a second form asking
more specific questions of the user. Because it is tedious for users to
reenter the same basic information from the first form, you can program
the server to put the originally submitted values back into the second
form in hidden fields. When the second form comes back, all the import-
ant information from both forms is there, and the second form can be
matched to the first one, if necessary.
Hidden fields also may direct the server toward some specific action. For
example, you might embed the following hidden field:
<input type=hidden name=action value=change>
Then, if you have one server-side application that handles the process-
ing of several forms, each form might contain a different action code to
help that server application sort them out.