Ok, as an extension of this problem, I also realized that the input
forms themselves could still be submitted by hitting 'enter' (in
safari), so I am trying to get htem to disable themselves, but for
some unbelievably frustrating reason, they stay enabled:

                function timeOutButton() {

                        $('#form-name').val("").attr("disabled","disabled");
                        $('#form-message').val("").attr("disabled","disabled");

                        var countdown;
                        var timer = <?=POST_FREQUENCY?>;
                        if ($('#form-submit').val() == 'say hi!') {
                                $('#form-submit').attr('disabled','disabled');
                                 countdown = setInterval(function() {
                                         if (timer > 0) {
                                                 $('#form-submit').val(timer);
                                                 timer = timer -1;
                                         } else {
                                                $('#form-submit').val('say 
hi!');
                                                
$('#form-submit').removeAttr('disabled');
                                                clearInterval(countdown);
                                                return;
                                         }
                                 }, 1000);

                        }
                        $('#form-name').removeAttr('disabled');
                        $('#form-message').removeAttr('disabled');
                }

If anyone has any idea why this code simply isn't working, it would be
greatly appreciated.

thank you!
alan

On Mar 8, 12:10 pm, alan <[EMAIL PROTECTED]> wrote:
> 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