Do not know how to use the HTML5 hidden property? Then take a look at the usage of the form hidden property

Source: Internet
Author: User
This article mainly introduces the usage of the new hidden attribute in HTML5, introduces the usage of the hidden property about the <p> tag, and the usage introduction in the form label, let's read this article now.

First, let's start by saying hidden properties:

This is a new property in the HTML5, in the <p> tag can be hidden, the browser does not see, see this example:


I put a hidden attribute in the middle, and the rest, as well as the other, to see the result

There are only four lines, and the middle line disappears.

Once you know the basic usefulness of this property, let's look at what the hidden property in the form will mean.

Second, the function of the form hidden attribute:

    • Hidden fields are not visible to the user in the page, and inserting hidden fields in the form is intended to collect or send information for use by the program that processes the form. When the browser clicks the Send button to send the form, the hidden field information is also sent to the server.

    • Sometimes we have to give the user information, let him submit the form when submitted to confirm identity, such as: sessionkey,etc, of course, these things can also be implemented with cookies, but the use of hidden fields is much simpler, and there will be no browser does not support the user to disable cookies annoyance.

    • Sometimes there are multiple commit buttons in a form, so how can the program tell which button the user is submitting to? We can write a hidden field and add onclick= "document.form.command.value=" xx to each button. "And then we check the command value after we receive the data and we know which button the user is pressing to submit."

    • Sometimes there are multiple form in a Web page, we know that multiple form can not be submitted at the same time, but the form does interact with each other, we can add hidden fields in the form to connect them.

    • JavaScript does not support global variables, but sometimes we have to use global variables, we can put the value in the hidden field first, its value will not be lost.

    • Another example, such as pressing a button to pop up four small windows, when you click on one of the small window, the other three automatically closed. However, IE does not support small windows to call each other, so only in the parent window to write a hidden field, when the small window to see that the value of the hidden field is close when you turn off.

Example: Using hidden to implement the Click submit button number plus 1, numeric increment. htm

<form action= "Numeric increment. ashx" method= "POST" > <input type= "hidden" name= "_viewstate" value= "a"/> <input type= "Hidden" name= "_div" value= "@n"/> <!--<input name= "txt" type= "text" value= "@value"/>--> <div>@n& Lt;/div> <input type= "Submit" value= "click"/> </form>

Well, the above is about the use of the HTML5 hidden attribute in two places. If you have questions, you can ask questions below.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.