HTML formaction Attribute

HTML formaction Attribute: The HTML formaction attribute defines where to send the form-data when it is submitted.

HTML formaction Attribute

This attribute can be applied to <button>,<input> elements.

Browser Support

This attribute is supported by the following browsers:

  • Chrome-9.0
  • Opera-10.6
  • Safari-5.1
  • Firefox-4.0
  • Internet Explorer-10.0

Example:for <button> element

<!DOCTYPE html>
<html>
<body>

<form action="/action_page.php" method="get">
  First name: <input type="text" name="fname"><br>
  Last name: <input type="text" name="lname"><br>
  <button type="submit">Submit</button><br>
  <button type="submit" formaction="/action_page2.php">Submit to another page</button>
</form>
</body>
</html>

Output:

HTML formaction attribute button element

 

Example: for <input> element

<!DOCTYPE html>
<html>
<body
<form action="/action_page.php">
  First name: <input type="text" name="fname"><br>
  Last name: <input type="text" name="lname"><br>
  <input type="submit" value="Submit"><br>
  <input type="submit" formaction="/action_page2.php" value="Submit to another page">
</form>
</body>
</html>

Output:

HTML formaction attribute input element