Skip to main content
July 5, 2006
Question

How to prevent double click?

  • July 5, 2006
  • 3 replies
  • 574 views
How du I prevent a user to dubbleclick on a link and then submitting the page twice?
I'm using the code below:


function UpdateApplication(inc){
document.DataForm.Inc.value=inc;
document.DataForm.submit();
}

……

<a href="Javascript: UpdateApplication(1);" target="_self" onMouseOver="self.status='Update Application'; return true;" onMouseOut="self.status=''; return true;">
<img src="/layout/buttons/Save.gif" alt="Update Application" border="0">
</a>

Any ideas?
This topic has been closed for replies.

3 replies

Inspiring
July 11, 2006
I believe the following will work for you. But use 'onclick' to call your Javascript function as in the example below.
The function sets a variable as a switch. If the switch is zero the first time the link is clicked, the function sets the switch to 1 and submits the form. If the user clicks the link again, the switch has already been changed and the form is not submitted.

<script language="JavaScript">
dbl_stop = 0
function UpdateApplication(inc){
if(dbl_stop == 0){
dbl_stop = 1;
document.DataForm.Inc.value=inc;
document.DataForm.submit();
}
}
</script>

<a href="javascript:void(0);" onclick="UpdateApplication(1)" target="_self" onMouseOver="self.status='Update Application'; return true;" onMouseOut="self.status=''; return true;">
<img src="/layout/buttons/Save.gif" alt="Update Application" border="0">
</a>
Participant
July 5, 2006
You might also want to look at Qforms by PengoWorks. It is a Javascript API that automatically includes this functionality. You also get form validation which works great.
July 5, 2006
This is what i do is this.

<form name="formJob" id="formJob"
[...]
onsubmit="document.getElementById('formJob__submit').disabled=true;">
<input class="majorBtn" id="formJob__submit" type="submit" value="Go />
</form>

PS
You don't need to do this in for Firefox, only IE
July 6, 2006
quote:

Originally posted by: monkey woo too
This is what i do is this.

<form name="formJob" id="formJob"
[...]
onsubmit="document.getElementById('formJob__submit').disabled=true;">
<input class="majorBtn" id="formJob__submit" type="submit" value="Go />
</form>

PS
You don't need to do this in for Firefox, only IE



This does not work.

I guess it is because i'm using a <a href> and anot an <Input> tag.

Any other sugestions. I think that it will be hard to prevent double clicks on a <a href>.

I would prefere not to use a third party product. Anyway I'm not sure if their solution will work on a <a href> anyway.