Hey Mark,

The plugin uses a recursive function to achieve the countdown.  You
can cancel the countdown by checking a global variable with each
decrement in the number.

Line 19:
        $(this).animate({
            'fontSize': settings.endFontSize
        },settings.duration,'',function() {
            if (cancel_countdown == 1) return;  // this cancels the
countdown
            if(to > settings.endNumber + 1) {
                $(this).css('fontSize',settings.startFontSize).text(to
- 1).countDown(settings,to - 1);
            }
            else
            {
                settings.callBack(this);
            }
        });


You'll need to set the global variable 'cancel_countdown' when
starting, and canceling the countdown.

HTML:

<input id="start_countdown" type="button"></input>
<input id="cancel_countdown" type="button"></input>

More jQuery:

$("input#start_countdown").click(function(){
    // start countdown code
    cancel_countdown = 0;
});
$("input#stop_countdown").click(function(){
   cancel_countdown = 1;
});


Hope this helps,
Renato.

On Nov 12, 4:39 pm, Mark <mark...@gmail.com> wrote:
> Hi,
>
> i tried this jquery countdown 
> plugin:http://davidwalsh.name/jquery-countdown-pluginand it works neat.. but
> not for my interest.
> What i try to do is have this:
>
> Have a simple countdown that counts down from 5 to 0 then changes the
> text to "Uploading..."
> The plugin mentioned can do that but i also want to be able to
> "cancel" the countdown which it can't do.
> Can anyone point me to a plugin that does have that functionality? or
> how i make that in this plugin..
>
> So what i want to be able to do:
>
> 5
> 4
> 3
> 2
> 1
> 0
> Uploading...
>
> Or when cancel is pressed
>
> 5
> 4
> 3
> 2
> CANCEL
>
> Just like that.
>
> I hope anyone can help me with this.
>
> Thanx,
> Mark.

Reply via email to