Home  >  Article  >  Backend Development  >  表单

表单

WBOY
WBOYOriginal
2016-06-23 13:53:51915browse

我有一个表单。上传后转到一个新页面。

现在的问题是如何用户单击浏览器后退按钮后,表单中已被输入的内容依然存在。这样用户就有可能再次单击上伟。导致重复提交和连续提交。

我想问怎么在用户单击后退按钮时表单内容被清空。


回复讨论(解决方案)

在页面 body上加个onload事件,一载入就执行重置表单reset操作



<script> <br /> function reset_form() { <br /> document.getElementById('form1').reset(); <br /> } <br /> </script>



<script> <br /> function reset_form() { <br /> document.getElementById('form1').reset(); <br /> } <br /> </script>

您好
我感觉还是用PHP可靠一点

表单页启用 session 就不保存了

PHP毕竟是后端的语言,可以验证数据是否重复,但页面清空表单还是需要前端来实现的~~

单击后退是浏览器行为,这个时候用js比php靠谱

你所看到的内容是在前端的,所以用JS来处理比较合适

js操作 初始化页面,input 的值被清空。

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn