如何指定在 HTML 中提交表单时将表单数据发送到何处?

htmlweb developmentfront end technology更新于 2025/8/14 13:00:17

使用 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>

相关文章


有用资源