HTML formaction Attribute
Example
<form action="action.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="action2.html">Submit to another link</button>
</form>
Meaning
The formaction attribute specifies a URL to target when the button/input is clicked, similar to the use of the action attribute on a form element.
Note: The formaction attribute is only used with type="submit".
Standard Syntax
<element formaction="URL">
Browser Support
Status
Applies to:
The formaction attribute can be used on the following element:
Element | Attribute |
---|---|
<button> | formaction |
<input> | formaction |
Attribute Values
Value | Description |
---|---|
URL | Value can be
|
More Examples:
Example
<form action="action.php">
<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>
<input type="submit" value="Submit">
<input type="submit" formaction="action2.php" value="Submit to another page">
</form>