如何实现刷新的时候表单不再次提交

来源:百度知道 编辑:UC知道 时间:2024/06/07 05:39:26
谢谢了啊。.

第一种:用flag标识,下面的代码设置checkSubmitFlg标志:

<script language=”javascript”>
var checkSubmitFlg = false;
function checkSubmit(){
if(checkSubmitFlg ==true){
return false; //当表单被提交过一次后checkSubmitFlg将变为true,根据判断将无法进行提交。
}
checkSubmitFlg ==true;
return true;
}
< /script >
<form name=”form1” method=”post” onsubmit=”return checkSubmit();”>
………..
</form>

第二种:在onsubmit事件中设置,在第一次提交后使提交按钮失效,代码如下:

<form action=”about:blank” method=”post”
onsubmit =”getElementById(‘submitInput’).disabled=true; return true;”
target=”_blank”>
<input type=”submit” id=”submitInput”/>
</form>

第三种:同上一方法,只是使提交按钮隐藏,代码如下:

<form action=”about:blank” method=”post”
onsubmit =”getElem