List Info

Thread: Re: Stopping double clicking with Perl CGI




Re: Stopping double clicking with Perl CGI
country flaguser name
United Kingdom
2008-05-22 04:38:15
On Thu, 2008-05-22 at 10:17 +0100, Chris Jack wrote:
> It seems to me that the logical way to do it would be
to disable the
> button when it is pressed, but I haven't found an
example of how to do
> that on the web yet.

At the risk of having missed something; this is usually done
(very
simply) with Javascript.

Google suggests:
<input type="submit" ...
onclick="this.disable = true" />


For bonus points, figure out how to re-enable the button
after a few
seconds, so that if the submit hangs and drops out they can
try
resubmitting it.  (I have no idea if that's possible, but it
would be a
neat solution to the main annoying problem with
self-disabling submit
buttons)


Re: Stopping double clicking with Perl CGI
user name
2008-05-22 05:18:55
> For bonus points, figure out how to re-enable the
button after a few
> seconds, so that if the submit hangs and drops out they
can try
> resubmitting it.  (I have no idea if that's possible,
but it would be a
> neat solution to the main annoying problem with
self-disabling submit
> buttons)

<input id="a" type="submit"
onclick="this.disabled =
true;setTimeout('document.getElementById('a').disabled =
false;',2000);" />
seems to work.

Adam

Re: Stopping double clicking with Perl CGI
country flaguser name
United Kingdom
2008-05-22 05:31:25
On 22 May 2008, at 11:18, Adam Bernard wrote:

>> For bonus points, figure out how to re-enable the
button after a few
>> seconds, so that if the submit hangs and drops out
they can try
>> resubmitting it.  (I have no idea if that's
possible, but it would  
>> be a
>> neat solution to the main annoying problem with
self-disabling submit
>> buttons)
>
> <input id="a" type="submit"
onclick="this.disabled =
>
true;setTimeout('document.getElementById('a').disabled =
> false;',2000);" />
> seems to work.


eval() (and passing a string to setTimeout is an eval)
considered  
harmful. There's no need for an id in this instance either.

onclick="this.disabled=true;setTimeout(function(foo){re
turn function() 
{foo.disabled=false}}(this)
,2000);"

-- 
David Dorward
http://dorward.me.uk/
http://blog.dorward.me.uk/




Re: Stopping double clicking with Perl CGI
country flaguser name
United Kingdom
2008-05-22 07:08:30
On Thu, May 22, 2008 at 10:38:15AM +0100, Denny wrote:

> Google suggests:
> <input type="submit" ...
onclick="this.disable = true" />
> 
> For bonus points, figure out how to re-enable the
button after a few
> seconds, so that if the submit hangs and drops out they
can try
> resubmitting it.  (I have no idea if that's possible,
but it would be a
> neat solution to the main annoying problem with
self-disabling submit
> buttons)

Presumably something along the lines of ...

  "this.disable=true;sleep(10);this.text='Try
again';this.disable=false"

-- 
David Cantrell | A machine for turning tea into grumpiness

     Repent through spending

[1-4]

about | contact  Other archives ( Real Estate discussion Medical topics )