HTML <button> Thuộc tính formaction

❮ Thẻ HTML <button>

Thí dụ

Một biểu mẫu có hai nút gửi. Nút gửi đầu tiên gửi dữ liệu biểu mẫu tới "action_page.php" và nút thứ hai gửi tới "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>

Định nghĩa và Cách sử dụng

Thuộc formactiontính chỉ định nơi gửi dữ liệu biểu mẫu khi biểu mẫu được gửi. Thuộc tính này ghi đè thuộc tính của biểu mẫu action.

Thuộc formactiontính chỉ được sử dụng cho các nút có type="submit".


Hỗ trợ trình duyệt

Các số trong bảng chỉ định phiên bản trình duyệt đầu tiên hỗ trợ đầy đủ thuộc tính.

Attribute
formaction 9.0 10.0 4.0 5.1 15.0

Cú pháp

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

Giá trị thuộc tính

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

❮ Thẻ HTML <button>