Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What is the function of html hidden domain

2025-03-29 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/02 Report--

This article mainly introduces "what is the function of html hidden domain". In daily operation, I believe that many people have doubts about the role of html hidden domain. The editor consulted all kinds of materials and sorted out simple and easy-to-use operation methods. I hope it will be helpful for you to answer the doubts about "what is the role of html hidden domain?" Next, please follow the editor to study!

Html hidden fields refer to the form elements in a web page that are not visible to the user. The purpose of inserting hidden fields in a form is to collect or send information for use by programs that process the form.

The operating environment of this tutorial: windows7 system, HTML5 version, Dell G3 computer.

Hidden field: refers to the form elements in a web page that are not visible to the user, that is, hidden form elements.

Basic syntax:

Function:

Hidden fields are not visible to users on the page, and the purpose of inserting hidden fields in the form is to collect or send information for use by programs that process the form. When the viewer clicks the send button to send the form, the information about the hidden field is also sent to the server.

Sometimes we have to give the user a message and ask him to submit the form to determine the user's identity, such as sessionkey, etc. Of course, these things can also be implemented in cookie, but it is much easier to use hidden fields. And there will be no trouble that browsers don't support it and users disable cookie.

Sometimes there are multiple submit buttons in a form. How can the program tell which button the user pressed to submit it? We can write a hidden field, and then add onclick= "document.form.command.value=" xx "" to each button, and then when we receive the data, we will check the value of command and we will know that the user pressed the button to submit it.

Sometimes there are multiple form in a web page, and we know that multiple form cannot be submitted at the same time, but sometimes these form do interact with each other, so we can add hidden fields to the form to connect them.

Javascript does not support global variables, but sometimes we have to use global variables, so we can store the value in the hidden field first, and its value will not be lost.

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

Example: use hidden to implement click submit button number plus 1

The value is self-increasing. Htm

The code is as follows:

@ n

Use general handlers to achieve self-increment. Ashx

The code is as follows:

Int n = 0; public void ProcessRequest (HttpContext context) {context.Response.ContentType = "text/html"; string path = context.Request.MapPath ("numerical self-increment .htm"); string html = System.IO.File.ReadAllText (path); / / determine whether the page is loaded for the first time string viewstate = context.Request.Form ["_ viewstate"] If (! string.IsNullOrEmpty (viewstate)) {/ / Click the button post / / to get the value of the hidden field string s = context.Request.Form ["_ div"]; if (int.TryParse (s, out n)) {n domains; html = html.Replace ("@ n", n.ToString ());}} else {/ / page is loaded for the first time, assigning html = html.Replace ("@ n", n.ToString ()) to the hidden fields corresponding to div and div } context.Response.Write (html);} at this point, the study of "what is the role of html hidden domain" is over, hoping to solve everyone's doubts. The collocation of theory and practice can better help you learn, go and try it! If you want to continue to learn more related knowledge, please continue to follow the website, the editor will continue to work hard to bring you more practical articles!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report