For a form form that has a GET request method, the Action property cannot have a parameter after the problem

Source: Internet
Author: User

If you have the following code on the page:

<form action= "xxx?name=jack&age=10" >
<input type= "text" name= "address" value= "Beijing"/>
<input type= "hidden" name= "sex" value= "male"/>
<input type= "Submit" value= "Submit"/>
</form >

Then the background cannot get the name and age parameters in the Action property. This is because the browser encapsulates the data in the form as a string, for example by encapsulating the address and sex attributes above as Address=beijing&sex=male, and then attaching them directly to the action URL . There will be a '? ' between the URL and the encapsulated string. Separated. If the parameter is already included in the form's Action property, the browser filters it out and appends the form data. Therefore, the request method is a get form, its Action property can not carry parameters, if you want to implement parameter delivery, there are three ways:
1, the use of post mode for delivery, you can add parameters in action;
2, if you want to use the Get method, then you can use the above method, through the form data transmission, for example:

<input type= "hidden" name= "name" value= "Jack"/> <input
type= "text" name= "age" value= "/>"

3. Use hyperlinks (the default request mode for hyperlinks is get):

<a href= "xxx?name=jack&age=10" > Submit </a>

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.