在web开发中怎么解决重复提交的
1个回答
展开全部
1 javascript ,设置一个变量,只允许提交一次。
<script language="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>
<html:form action="myAction.do" method="post" onsubmit="return checkSubmit();">
2 还是javascript,将提交按钮或者image置为disable
<html:form action="myAction.do" method="post" onsubmit="getElById('submitInput').disabled = true; return true;"> <html:image styleId="submitInput" src="images/ok_b.gif" border="0" /> </html:form>
<script language="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>
<html:form action="myAction.do" method="post" onsubmit="return checkSubmit();">
2 还是javascript,将提交按钮或者image置为disable
<html:form action="myAction.do" method="post" onsubmit="getElById('submitInput').disabled = true; return true;"> <html:image styleId="submitInput" src="images/ok_b.gif" border="0" /> </html:form>
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询