Hidden Fields

Sometimes there are values that you want to pass along as part of the form that you want to give a predefined value to. Perhaps you have similar forms that can be submitted from more than one page and you want to identify the page that it was submitted from. Whatever the reason, it is simple to add extra fields to what is passed when the form is submitted by adding hidden fields.

<input type="hidden" id="mycode" name="mycode" value="xyz" />

I haven't included a sample page showing a form that only has a hidden field as such a form would make no sense whatever as there would be nothing to see. Instead we just add the appropriate input tag to define our hidden field anywhere in the form (immediately after the form tag is a good place to put any hidden fields).

In the case of hidden fields there is nothing to display on the page and so a hidden field dies not need a label. Again like the text and password fields we define the field using type="hidden". The id attribute is not needed to provide link the associated label but it may be required if you wish to refer to the field from Javascript. The two attributes that are mnecessary with hidden fields are the name and value attributes since they define the field and contents that will be sent when the form is submitted.


This article written by Stephen Chapman, Felgall Pty Ltd.

go to top

FaceBook Follow
Twitter Follow