HTML and buttons and formaction properties

HTML button formaction property HTML slt;button-and-label

When you use the formaction property, the form's submission address uses the value of the property itself, not the value of the action property of the label, refer to the following example:

Form with two submit buttons (with different actions), the first submit button to submit the form data to demo_form.html, and the second submit button to submit the form data to demo_admin.html:

<form action="demo_form.html" method="get">
First name: <input type="text" name="fname"><br>
Last name: <input type="text" name="lname"><br>
<button type="submit">提交</button><br>
<button type="submit" formaction="demo_admin.html">提交</button>
</form>

Try it out . . .

Browser support

HTML button formaction property HTML button formaction property HTML button formaction property HTML button formaction property HTML button formaction property

Internet Explorer 10, Firefox, Opera, Chrome, and Safari support formaction properties.

Note: Formaction properties are not supported by Internet Explorer 9 and earlier versions of IE.


Definitions and usages

The formaction property overrides the action property of the form element.

This property is used in conjunction with type "submit".


The difference between HTML 4.01 and HTML5

The formaction property is a new property in HTML 5.


Grammar

<button type="submit" formaction="URL">

The property value

value describe
URL Specifies the address sent to the form data.

Possible value:

  • Absolute URL - Complete page URL address (such as href = "http://www.example.com/formResult.html" Rel = "External Nofollow" target = "_ blank")
  • Relative URL Address - Point to a file of the current website (eg href = "formresult.html")


HTML button formaction property HTML slt;button-and-label