HTML <button> formaction Attribut
Beispiel
Ein Formular mit zwei Senden-Buttons. Die erste Submit-Schaltfläche sendet die Formulardaten an „action_page.php“ und die zweite an „action_page2.php“:
<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>
Definition und Verwendung
Das formaction
Attribut gibt an, wohin die Formulardaten gesendet werden, wenn ein Formular gesendet wird. Dieses Attribut überschreibt das Attribut des Formulars action
.
Das formaction
Attribut wird nur für Schaltflächen mit verwendet
type="submit"
.
Browser-Unterstützung
Die Zahlen in der Tabelle geben die erste Browserversion an, die das Attribut vollständig unterstützt.
Attribute | |||||
---|---|---|---|---|---|
formaction | 9.0 | 10.0 | 4.0 | 5.1 | 15.0 |
Syntax
<button type="submit" formaction="URL">
Attributwerte
Value | Description |
---|---|
URL | Specifies where to send the form data. Possible values:
|
❮ HTML <button>-Tag