Atributo de formación HTML <button>

❮ Etiqueta HTML <botón>

Ejemplo

Un formulario con dos botones de envío. El primer botón de envío envía los datos del formulario a "action_page.php", y el segundo lo envía a "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>

Definición y uso

El formactionatributo especifica dónde enviar los datos del formulario cuando se envía un formulario. Este atributo anula el atributo del formulario action.

El formactionatributo solo se usa para botones con type="submit".


Compatibilidad con navegador

Los números de la tabla especifican la primera versión del navegador que es totalmente compatible con el atributo.

Attribute
formaction 9.0 10.0 4.0 5.1 15.0

Sintaxis

<button type="submit" formaction="URL">

Valores de atributo

Value Description
URL Specifies where to send the form data.

Possible values:

  • An absolute URL - the full address of a page (like href="http://www.example.com/formresult.asp")
  • A relative URL - points to a file within the current site (like href="formresult.asp")

❮ Etiqueta HTML <botón>