Stopping double clicking with Perl CGI
David Dorward
david at dorward.me.uk
Thu May 22 14:51:28 BST 2008
On 22 May 2008, at 14:23, Chris Jack wrote:
> Thank for all the replies. My opinion of CGI has gone down as a
> result of the various discussions... As I understand it, and correct
> me if I'm wrong on any of this:
>
> 1) If I disable the push button then run another perl script to
> process my results -> if I then push the back button the push button
> is still disabled on the first screen as I cannot pick up that the
> back button has been pressed. Hitting refresh would fix this - but I
> think that sort of user intervention is very bad.
Hitting refresh wouldn't fix it, since many browsers remember form
control state.
As mentioned, you can re-enable it with an onDomReady event handler
(although I confess to only testing in Firefox).
> 2) If I disable the push button, then run another perl script, I
> cannot put a timer on to re-enable it on the initial screen.
That screen isn't there, so it isn't an issue. If they go back, see (1).
> 3) If I disable the push button for 1 second then re-enable it then
> run another perl script - not only have I wasted a second of each
> user's life, it's still not safe because they can click on the push
> button after that second has elapsed.
Yes, doing that would be silly.
> So I'm thinking that I could do 1 - but have a push button on the
> next screen to go back to the first screen. Still not what I would
> describe as good.
It often makes sense for a result page to have a link forward (not
back) to the form.
> Oh - and given that this seems like a pretty fundamental sort of
> issue, I am disappointed that my CGI Programming with Perl doesn't
> even mention it, let alone suggest a robust solution.
Solutions vary depending on what data you are taking from the user and
what you are doing with it. Some form of duplicate detection (followed
by update, discard or warn) is usually the best approach.
--
David Dorward
http://dorward.me.uk/
http://blog.dorward.me.uk/
More information about the london.pm
mailing list