Introduction to the method attribute of the Form form in HTML

Introduction to the method attribute of the Form form in HTML
1 method is a property that specifies how data is sent to the server
2 It can only be post and get post: The official explanation is to transfer data to the server through the post session. It actually submits data. get: Add the data in the form to the URL pointed to by action in the form of variable=value, and connect the two with "?", and connect each variable with "&"; generally used to get data from the server.
3. The default is get, so we usually specify it as post

For example:

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

Copy code
The code is as follows:

<form id="form1" method="get" action="b.asp">
<input name="Text1" type="text" value="11" />
<input id="Submit1" type="submit" value="submit" />
</form>

There are two places to note in the above code:

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

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

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

If you don't want the value to be displayed in 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 gets the value and outputs it through <% =Request.QueryString["Text1"]%>;
When method=post, the b.asp page obtains and outputs the value through <% =Request.Form["Text1"]%>.

<<:  When should a website place ads?

>>:  Detailed explanation of the this pointing problem of JavaScript prototype objects

Recommend

MySQL obtains the current date and time function example detailed explanation

Get the current date + time (date + time) functio...

Html/Css (the first must-read guide for beginners)

1. Understanding the meaning of web standards-Why...

How to handle spaces in CSS

1. Space rules Whitespace within HTML code is usu...

Detailed explanation of Javascript event capture and bubbling methods

Table of contents 1. Event Processing Model 1. Ev...

Detailed explanation of how to monitor MySQL statements

Quick Reading Why do we need to monitor SQL state...

What is the base tag and what does it do?

The <base> tag specifies the default addres...

Detailed explanation of the installation process of Jenkins on CentOS 7

Install Jenkins via Yum 1. Installation # yum sou...

How to solve the problem of character set when logging in to Linux

Character set error always exists locale: Cannot ...

How to use mysql index merge

Index merging is an intelligent algorithm provide...

Detailed explanation of the role of static variables in MySQL

Detailed explanation of the role of static variab...

Ubuntu 20.04 firewall settings simple tutorial (novice)

Preface In today's increasingly convenient In...

Detailed explanation of data types in JavaScript basics

Table of contents 1. Data Type 1.1 Why do we need...

4 ways to modify MySQL root password (summary)

Method 1: Use the SET PASSWORD command First log ...

Instructions for using the meta viewport tag (mobile browsing zoom control)

When OP opens a web page with the current firmwar...