1

Here is my client website http://www.tswanda.co.zw/campaigns/tswanda-childrens-home/ when you click on contribute now a popup window appear with donate button, if you click on donate button 2, 3 or 4 times it submitted the value again for checkout.

I want to disable button once a money is submitted can you please help me out i tried hard use code from Disabling links to stop double-clicks in JQuery but nothing work for me.

any help will be really appreciated.

<script type="text/javascript"> function do_nothing() { return false; } // prevent a second click for 10 seconds. :) jQuery('.edd-add-to-cart').live('click', function(e) { jQuery(e.target).click(do_nothing); setTimeout(function(){ jQuery(e.target).unbind('click', do_nothing); }, 50000); }); </script> 
4
  • 1
    Share the code what you've tried Commented Mar 19, 2015 at 11:11
  • thanks for checking sir..i add code Commented Mar 19, 2015 at 11:15
  • 1
    check out this fiddle jsfiddle.net/L1y2xmhx Commented Mar 19, 2015 at 11:26
  • Try this: jsfiddle.net/mohamedrias/u04qgaLt and check my answer for implementation Commented Mar 19, 2015 at 13:42

3 Answers 3

1

You can disable the button when clicked, and re-enable it after 5 seconds:

 jQuery('.edd-add-to-cart').live('click', function(e) { var element = $(this); jQuery(e.target).click(do_nothing); element.attr("disabled", "disabled"); setTimeout(function(){ element.removeAttr("disabled"); }, 50000); }); 
Sign up to request clarification or add additional context in comments.

Comments

0

try this

<input type="submit" name="Submit" value="Submit" onclick="this.disabled=true; this.value='Please Wait...';" /> 

Comments

0

Inside your click handler,You are binding another click event to the target. And you're removing that particular click handler.

Instead the try disabling the button by setting up disabled attribute and remove it.

function do_something() { alert("doing something"); } // prevent a second click for 10 seconds. :) jQuery('.edd-add-to-cart').live('click', function (e) { var self = this; $(this).attr("disabled", "disabled"); do_something(); setTimeout(function () { $(self).removeAttr('disabled'); }, 10000); }); 

DEMO

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.