Hi Karl,
Thanks a ton, that works absolutely perfectly, I think that setting
the interval is definitely a better way than using the animate trick
for something like this! Not only that, I didn't know about firebug
before which is now a huge help! I was struggling with setting manual
alerts all over the place beforehand!

thanks again!
alan

On Mar 8, 9:44 am, Karl Swedberg <[EMAIL PROTECTED]> wrote:
> Hi Alan,
>
> This should do the trick (tested in Firebug):
>
> var countdown;
> var timer = 5;
> if ( $('#form-submit').val() == 'Submit') {
>      countdown = setInterval(function() {
>          if (timer > 0) {
>              $('#form-submit').val(timer);
>              timer = timer -1;
>          } else {
>             $('#form-submit').val('Submit');
>             clearInterval(countdown);
>             return;
>          }
>      }, 1000);
>
> }
>
> --Karl
> _________________
> Karl Swedbergwww.englishrules.comwww.learningjquery.com
>
> On Mar 8, 2008, at 5:56 AM, alan wrote:
>
>
>
> > Hi,
> > I am trying to get a submit button, once clicked, to disable itself,
> > countdown, then reenable itself to prevent a form from being submitted
> > too rapidly.
>
> > I've figured it out, but in a way that I think is pretty messy and not
> > very scalable, I'm wondering if I am going about this the wrong way
> > and if there is a more efficient way to code something like this?
>
> > ---
>
> > $("#form-submit").attr("value",5).animate({opacity: 1.0}, 1000,
> > function() {
> >                            
> > $("#form-submit").attr("value",4).animate({opacity: 1.0}, 1000,
> > function() {
> >                                    
> > $("#form-submit").attr("value",3).animate({opacity: 1.0}, 1000,
> > function() {
> >                                            
> > $("#form-submit").attr("value",2).animate({opacity: 1.0}, 1000,
> > function() {
> >                                                    
> > $("#form-submit").attr("value",1).animate({opacity: 1.0}, 1000,
> > function(){
> >                                                            
> > $("#form-submit").attr("disabled",false);
> >                                                            
> > $("#form-submit").attr("value","Submit");
> >                                                    })
> >                                            })
> >                                    })
> >                            })
> >                    });
>
> > ---
>
> > Thanks a lot!
>
> > Alan

Reply via email to