如何在 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 次浏览

开启你的 职业生涯

通过完成本课程获得认证

开始
广告
© . All rights reserved.