HTML -Formation- Attribut


Definition und Verwendung

Das formactionAttribut gibt an, wohin die Formulardaten gesendet werden, wenn ein Formular gesendet wird. Dieses Attribut überschreibt das Attribut des Formulars action.

Das formactionAttribut wird nur für Eingänge/Schaltflächen mit verwendet type="submit".


Gilt für

Das formactionAttribut kann für die folgenden Elemente verwendet werden:

Elemente Attribut
<Schaltfläche> Formation
<Eingabe> Formation

Beispiele

Schaltflächenbeispiel

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

Eingabebeispiel

Ein HTML-Formular mit zwei Senden-Schaltflächen mit unterschiedlichen Aktionen:

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

Browser-Unterstützung

Das formactionAttribut hat die folgende Browserunterstützung für jedes Element:

Element
button 9.0 10.0 4.0 5.1 10.6
input 9.0 10.0 4.0 5.1 10.6