Stopping double clicking with Perl CGI

Toby Corkindale tjc at wintrmute.net
Thu May 22 10:48:29 BST 2008


On Thu, May 22, 2008 at 10:17:52AM +0100, Chris Jack wrote:
> I thought I'd be a disruptive element in the group and ask a Perl question.
>  
> What is the best way of stopping a user double clicking a button in a web
> page created using Perl CGI? I have written "my first web app" and the logs
> suggest one user double clicked in well less than a second. I want a
> programmatic solution rather than browser configuration solution.

Off the top of my head, load jquery.js then stick this inside some <script>
tags:
$(document).ready(function(){
  $('button').click(function(){
    $(this).attr('disabled', 'true');
  });
});

That'll disable any button that gets clicked.

For submit buttons, they're <input> rather than <button>, so you'd replace
every $('button') up there with $('input[type=submit]') instead.

cheers,
Toby


More information about the london.pm mailing list