button formaction Attribute - HTML CSS HTML Tag

HTML CSS examples for HTML Tag:button

Description

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

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

Attribute Values

Value Description
URL Specifies where to send the form data.

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":

Demo Code

ResultView the demo in separate window

<!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><!--   w ww . j  a v  a  2 s  . co  m-->

</body>
</html>

Related Tutorials