What does the Action property of the HTML form tag mean? And what are the uses? (attached example)

Source: Internet
Author: User
Tags html form
This article mainly introduces the use of the Action property of the HTML form label, the usage introduction and the instance are all inside, now let's see it together

First, let's introduce the meaning of the Action property about the HTML form tag:

The Action property of the form tag is a required property in a form, and the Action property specifies where to send the form data when the form is submitted.

Let's look at the first instance of the Action property on the form tag:

The following form has two input fields and a Submit button, and when the form is submitted, the form data is submitted to a page named "form_action.asp":

<form action= "form_action.asp" method= "get" >  <p> Enter user name: <input type= "text" name= "FName"/></ P>  <p> re-enter user name: <input type= "text" name= "lname"/></p>  <input type= "Submit" value= "Submit"/ ></form>

This is at the bottom:

The effect is obvious, and basically every form requires an action property.

Now tell me about the use of the form Tag Action property:

The value of the Action property in form form is the URL given by table single handle, and if we do not set the Action property, the default form is still submitted to the current page, and the following are three usage descriptions of the Action property:

    • Action= "" and action= "#" Do not have the same action property, and are committed to the current page (that is, document.location.href)

    • action= "Currentpage.xxx" If currentpage.xxx represents the current page, it is submitted to the current page, the colleague jumps to the current page, of course, the URL changes are not seen, if currentpage.xxx is not the current page, then submitted to the non-current page, also jump to the non-current page

    • The difference between action= "" and action= "currentpage.xxx" when the form is submitted to itself:

Usually for the sake of convenience, we generally set the form's Action property to Action= ""/action= "#" or simply do not write, but this will cause a problem, that is, when the action is set to Action= "", the form submitted when the actual page is action= " Currentpage.xxx?arguments=values&, that is, if the current page has parameters, the parameters will be submitted together, and the parameters will be given precedence over the parameters submitted by the <form> control, that is, if action= " Currentpage.xxx?arguments=values& arguments in the same time as the <form> element name, action= "currentpage.xxx when getting the value? Arguments=values&: The value overrides the value of <form> to get an incorrect value from the page.

Example: The spectop.asp page is the page to be submitted by the form, and there are parameters passed from the parent page.

action= "" Page when you really submitted: Spectop.asp? Classid=000100200005&speid=947&spetype=3

If <form> has <input type= "text" name= "Speid" value= "n"/>, the value obtained at the time of submission will be 947, not 1000, and action= " Currentpage.xxx "can get 1000

OK, the above is about the HTML form tag of the Action property of all the introduction, the problem can be in the message below.

Related Article

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.