Introduction to the method attribute of Form forms in HTML _ HTML/Xhtml _ webpage Creation

Source: Internet
Author: User
Method is an attribute that specifies how data is sent to the server. Actually, it is used to submit data. The following example shows how to use and pay attention to the method attribute of Form forms, if you are interested, refer to the attribute 1 method that specifies how data is sent to the server.
2 may only be post and get post: the official explanation is to transmit data to the server through the post session. Actually, data is submitted. Get: add the data in the form to the URL pointed to by action in the form of variable = value, and use "?" And variables are connected by "&". It is generally used to get data from the server.
3. The default value is get, so we usually need to specify it as post.

For example:

For example, if there are two pages, a.htmand B .asp, you want to pass the values in the.htm page form to the B. asp page.
In a.htm, there will be the following form code:

The Code is as follows:




Note the following two points in the above Code:

1. The property of method is get, so the value is visible through the URL;
2. There are two objects in the form, one text box and one submit button. The value of the text box must be passed. Change 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.htm page and click the submit button, the page goes to the B. asp page and the URL changes:

Http: // localhost/WebSite2/B. asp? Text1 = 11

If you do not want the value to be displayed at the url, replace the method value with post.

Then in B. asp, you can obtain the passed value through the server code.
When method = get, the B. asp page obtains and outputs the value through <% = Request. QueryString ["Text1"] %>;
When method = post, the B. asp page obtains and outputs the value through <% = Request. Form ["Text1"] %>.

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.