Home > Web Front-end > HTML Tutorial > Introduction to the use of method attributes of Form forms in HTML_HTML/Xhtml_Web page production

Introduction to the use of method attributes of Form forms in HTML_HTML/Xhtml_Web page production

WBOY
Release: 2016-05-16 16:39:42
Original
2819 people have browsed it

1 method is an attribute that specifies how to send data to the server
2 It can only be post and get post: the official explanation is to transmit the data to the server through the post session. The actual thing is to submit the data. get: Add the data in the form to the URL pointed to by the action in the form of variable=value, and use "?" to connect the two, and use "&" to connect each variable; generally used to get data from the server .
3, the default is get, so generally we have to specify it as post

For example:

For example, there are 2 pages, a.htm and b.asp, you want to pass the values ​​in the form of the a.htm page to the b.asp page.
Then there will be the following form code in a.htm:

Copy the code
The code is as follows:






Above There are two places in the code that need attention:

1. The attribute of method is get, so the value passed through the URL is visible;
2. There are two objects in the form, a text box, A submit button. What needs to be passed is the value of the text box. Pay attention to changing the id attribute of the text box to the name attribute so that the value of the text box can be displayed at the URL.

When you browse the a.htm page and click the submit button, the page goes to the b.asp page, and the URL becomes:

http://localhost/WebSite2/b.asp? Text1=11

If you don’t want the value to be displayed at the URL, just change the method value to post.

Then in b.asp you can get the passed value through the server-side code.
When method=get, the b.asp page passes <% =Request.QueryString["Text1"]%> to obtain the value and output it;
When method=post, the b.asp page passes <% =Request.Form["Text1"]%>Get the value and output it.
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template