如何通过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>
参考如下:
<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>
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询