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


使用操作屬性來新增檔案,在單擊“提交”按鈕後,這是你需要傳送到的位置。您還可以新增電子郵件,將資料傳送到該電子郵件 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>

更新日期:2020 年 3 月 2 日

516 次瀏覽

開啟你的 職業生涯

完成課程即可獲得認證

開始
廣告
© . All rights reserved.