| 订阅 | 在线投稿
分享
 
 
 

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

来源:互联网  宽屏版  评论
2008-08-08 06:10:24

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>

 
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>
󰈣󰈤
 
 
 
>>返回首页<<
 
 热帖排行
 
 
 
静静地坐在废墟上,四周的荒凉一望无际,忽然觉得,凄凉也很美
©2005- 王朝网络 版权所有