Home > Article > Web Front-end > What does the action attribute of the html form tag mean? What are the uses? (with examples)
This article mainly introduces the usage of the action attribute of the HTML form form tag. The usage introduction and examples are all in it. Now let us take a look at it.
First of all, let’s introduce it first Regarding the meaning of the action attribute of the HTML form tag:
The action attribute of the form tag is a necessary attribute in a form. The action attribute specifies where to send the form data when the form is submitted.
Let’s look at the first example of the action attribute of the form tag:
The form below has two input fields and a submit button. When the form is submitted, The form data will be submitted to the page named "form_action.asp":
<form action="form_action.asp" method="get"> <p>输入用户名: <input type="text" name="fname" /></p> <p>再输用户名: <input type="text" name="lname" /></p> <input type="submit" value="提交" /> </form>
The rendering of this is below:
The effect is obvious, basically every form requires the action attribute.
Now let’s talk about the usage of the action attribute of the form tag:
The value of the action attribute in the form form is the URL that the form is submitted to. If we do not set the action attribute , then the default form is still submitted to the current page. The following is an introduction to the three usages of the action attribute:
action="" and action="#", without the action attribute, have the same effect. , are submitted to the current page (that is, document.location.href)
The above is the detailed content of What does the action attribute of the html form tag mean? What are the uses? (with examples). For more information, please follow other related articles on the PHP Chinese website!