如何通过js控制刷新页面重复提交form表单问题

如题所述

1、用 javascript 设置一个变量,只允许提交一次;
参考如下:
<script type="text/javascript">
var checkSubmitFlg = false;
function checkSubmit(){
if (checkSubmitFlg == true){
return false;
}
checkSubmitFlg = true;
return true;
}
document.ondblclick =
function docondblclick(){
window.event.returnValue = false;
}
document.onclick =
function doconclick(){
if (checkSubmitFlg){
window.event.returnValue = false;
}
}
</script>
<form action="action.php" method="post" onsubmit="return checkSubmit();">

用 javascript 将提交按钮或者 img 置为 disable;
参考如下:
<form action="action.php" method="post" onsubmit="getElById('submitInput').disabled = true;return true;"> 
<img styleId="submitInput" src="images/ok_b.gif" border="0" />
</form>
温馨提示:答案为网友推荐,仅供参考
相似回答