• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

How to prevent double click?

Guest
Jul 05, 2006 Jul 05, 2006

Copy link to clipboard

Copied

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?
TOPICS
Advanced techniques

Views

430

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jul 05, 2006 Jul 05, 2006

Copy link to clipboard

Copied

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

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Jul 05, 2006 Jul 05, 2006

Copy link to clipboard

Copied

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.


Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jul 05, 2006 Jul 05, 2006

Copy link to clipboard

Copied

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.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Contributor ,
Jul 11, 2006 Jul 11, 2006

Copy link to clipboard

Copied

LATEST
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>

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources
Documentation