Computer >> Hướng Dẫn Máy Tính >  >> Lập Trình >> HTML

Đặt nơi gửi dữ liệu form khi submit trong HTML?

Sử dụng thuộc tính formaction trong HTML để đặt nơi gửi dữ liệu form khi form được submit.

Ví dụ

Bạn có thể chạy mã sau để triển khai thuộc tính formaction:

<!DOCTYPE html>
<html>
  <head>
    <title>Thuộc tính formaction trong HTML</title>
  </head>
  <body>
    <form action="/new1.php" method="get">
      Tên sinh viên: <input type="text" name="name"><br>
      Môn học: <input type="text" name="subject"><br>
      <button type="submit">Gửi</button><br>
      <button type="submit" formaction="/new2.php">Trang khác</button>
    </form>
  </body>
</html>