HTML - Hidden fields

  »   HTML forms  »   HTML Tutorial - Creating Hidden fields / Input tag

Hidden fields will not be shown by the browser. Those are necessary when we have to deal with forms and databases in MySQL, but it does not limit to that. We will use the hidden fields to send additional information to the database, in addition to the information sent by the user.

html<input type="hidden" />


This fragment of a code will not show anything because the browser treats it as information that must not be shown.

HTML - Other attributes

We will use the attributes name or id to establish a name for our hidden field.

html<input type="hidden" id="age" name="age" value="25" />

<input type="hidden" id="DOB" name="DOB" value="01/01/70" />

<input type="hidden" id="admin" name="admin" value="1" />

We exemplified above three models of hidden fields that could be of use, especially if you have a web page where the user will have to login in order to have access to certain information. The 'admin' field is used to verify someone's role, 1 being administrator, and 0 non-administrator.

HTML Hidden fields is also used when we have to deal with information that we want to put down in more than one form, not obligating the user to have to insert the information many times.