Horje

How to add HTML <button> formaction Attribute

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

Browser Support

The numbers in the table specify the first browser version that fully supports the attribute.

Syntax

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

Attribute Values

Value Description
URL Specifies where to send the form data.

Possible values:

  • An absolute URL - the full address of a page (like href="http://www.example.com/formresult.asp")
  • A relative URL - points to a file within the current site (like href="formresult.asp")
index.html
Example: HTML
<!DOCTYPE html>
<html>
<body>

<h1>The button formaction attribute</h1>

<form action="/action_page.php" method="get">
  <label for="fname">First name:</label>
  <input type="text" id="fname" name="fname"><br><br>
  <label for="lname">Last name:</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>

</body>
</html>

Output should be:

How to add HTML <button> formaction Attribute




Type:
html
Category:
Web Tutorial
Sub Category:
HTML Tag
Uploaded by:
Admin