JavaScript中避免Form重复提交的两种方案分享


 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>

—-想了解更多的linux相关异常处理怎么解决关注<计算机技术网(www.ctvol.com)!!>

本文来自网络收集,不代表计算机技术网立场,如涉及侵权请联系管理员删除。

ctvol管理联系方式QQ:251552304

本文章地址:https://www.ctvol.com/jspttutorial/64479.html

(0)
上一篇 2020年4月10日
下一篇 2020年4月10日

精彩推荐