html 表单 提交后重置,提交表单后重置textarea的值
时间: 2024-03-01 15:54:08 浏览: 34
可以使用JavaScript在表单提交后重置textarea的值。需要在表单的提交事件中添加代码,如下所示:
HTML代码:
```
<form id="myForm" onsubmit="resetTextarea()">
<textarea id="myTextarea"></textarea>
<input type="submit" value="Submit">
</form>
```
JavaScript代码:
```
function resetTextarea() {
var textarea = document.getElementById("myTextarea");
textarea.value = "";
}
```
在表单提交时,会调用名为resetTextarea的函数,该函数将textarea的值重置为空字符串。
相关问题
HTMLtextarea文本框怎么重置
A:可以使用JavaScript中的reset()方法来重置HTMLtextarea文本框。例如:
```html
<form action="#">
<textarea id="myTextarea">请输入内容</textarea>
<button type="button" onclick="resetTextarea()">重置</button>
</form>
<script>
function resetTextarea() {
document.getElementById("myTextarea").reset();
}
</script>
```
在上述代码中,我们创建了一个表单,并在其中添加了一个HTMLtextarea文本框和一个重置按钮。当用户点击重置按钮时,会调用resetTextarea()函数,并在该函数中使用document.getElementById()方法获取HTMLtextarea元素,并调用其reset()方法来进行重置操作。
帮我用HTML语言,使完成页面表单提交后直接发送到指定的邮箱发送完成之后反馈结果的页面代码
以下是一个基本的 HTML 表单,当提交表单后,会将内容发送到指定的邮箱,并在发送完成后返回结果页面:
```html
<!DOCTYPE html>
<html>
<head>
<title>表单提交</title>
</head>
<body>
<h1>请填写表单信息</h1>
<form action="mailto:指定的邮箱地址" method="post" enctype="text/plain">
<label>姓名:</label>
<input type="text" name="name"><br>
<label>邮箱:</label>
<input type="email" name="email"><br>
<label>信息:</label>
<textarea rows="5" name="message"></textarea><br>
<input type="submit" value="提交">
<input type="reset" value="重置">
</form>
<p>发送完成后,将返回此页面并显示发送结果。</p>
</body>
</html>
```
请注意,在上面的代码中,`action` 属性指定了表单要发送数据的目标邮箱地址,而 `enctype` 属性设置为 `text/plain`,表示以纯文本格式发送数据。此外,只要在请求头中使用 `mailto:` 协议指定了邮箱地址,就可以直接使用普通 HTML 表单提交数据,并将内容发送到指定的邮箱,而无需使用后端服务器脚本处理。
相关推荐
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)