HTML Hidden Fields.

Hello Friends,

I welcome you to my tutorial for hidden field. This control enables a developer to store a non-displayed value in the rendered HTML of the page. The Hidden Field control is used to store a value that needs to be persisted across multiple postbacks to the server. Hidden fields are similar to text fields, with one very important difference. The difference is that the hidden field does not show on the page. Therefore the visitor can’t type anything into a hidden field, which leads to the purpose of the field, to submit information that is not entered by the visitor.

A hidden HTML field is used to pass along variables without  values from one form to another page without forcing the user to re-enter the information. For example, in the case of form submission it may be required that certain information has to be submitted each time the form is submitted. And the information to be submitted is common all the time, then in this case it must be the concern of the developer to make that field Hidden since the developer knows its value and the user need not to fill the field all the time.

When dealing with forms you will usually find yourself using some sort of database mechanism such as MySQL, SQL Server, Oracle or maybe just a plain text file. In such cases use hidden fields in your form to pass along information to your database that you may have already been received from the user or you know the exact value to be submitted.

Consider the following code:

Here in this case the form contains three fields, among them only two fields are visible. But when the form is submitted the values from three fields will be stored into database. Since I know that the language for all the users will be English, I’ve made that field hidden and saved that value along with othre data from the form.

The visual output for the above code will be as follows:

And the main advantage of this is that it can be used in all the HTML supported scripting languages such as PhP, ASP ,JSP etc.

Thanks,

Nikhil Naoghare.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.