如何在 HTML 中指定在提交表單時將表單資料傳送到哪裡?


使用 action 屬性來新增檔案,單擊“提交”按鈕後要轉到該檔案所在的位置。你還可以新增電子郵件,將資料傳送到該電子郵件 ID。

示例

你可以嘗試執行以下程式碼,以設定在 HTML 中提交表單時將表單資料傳送到哪裡——

<!DOCTYPE html>
<html>
   <body>
      <h2>Student Contact Form</h2>
      <form action = "mailto:emailid@example.com" method = "post" enctype = "text/plain">
         Student Name:<br><input type = "text" name = "sname"> <br>
         Student Subject:<br><input type = "text" name = "ssubject"><br>
         <input type = "submit" value = "Send">
      </form>
   </body>
</html>

更新於: 02-Mar-2020

517 次瀏覽

開啟你的 職業生涯

透過完成本課程獲得認證

開始
廣告