HTML <button> formation Atribut

❮ HTML tag <button>

Příklad

Formulář se dvěma tlačítky pro odeslání. První tlačítko odeslat odešle data formuláře na „action_page.php“ a druhé odešle na „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>

Definice a použití

Atribut formactionurčuje, kam se mají odeslat data formuláře při odeslání formuláře. Tento atribut přepíše atribut formuláře action.

Atribut formactionse používá pouze pro tlačítka s type="submit".


Podpora prohlížeče

Čísla v tabulce určují první verzi prohlížeče, která tento atribut plně podporuje.

Attribute
formaction 9.0 10.0 4.0 5.1 15.0

Syntax

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

Hodnoty atributů

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

❮ HTML tag <button>