HTML <button> formaction Attribute

Definition and Usage

formaction attribute specifies where to send the form data when the form is submitted. This attribute overrides the form's action attribute.

formaction attribute is used only for type="submit" of buttons.

Example

A form with two submit buttons. The first submit button submits the form data to "action_page.php", and the second to "action_page2.php":

<form action="/action_page.php" method="get">
  <label for="fname">Name:</label>
  <input type="text" id="fname" name="fname"><br><br>
  <label for="lname">Surname:</label>
  <input type="text" id="lname" name="lname"><br><br>
  <button type="submit">Submit</button>
  <button type="submit" formaction="/action_page2.php">Submit to another page</button>
</form>

Try It Yourself

Syntax

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

Attribute Value

Value Description
URL

Specifies where to send the form data.

Possible values:

  • Absolute URL - The complete address of the page (e.g., href="http://www.example.com/formresult.asp")
  • Relative URL - Points to a file within the current site (e.g., href="formresult.asp")

Browser Support

Chrome Edge Firefox Safari Opera
Chrome Edge Firefox Safari Opera
9.0 10.0 4.0 5.1 15.0

Note:formaction Attributes are new properties in HTML 5.