Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

CGI and locking

by Ryszard (Priest)
on May 15, 2002 at 09:49 UTC ( [id://166677]=perlquestion: print w/replies, xml ) Need Help??

Ryszard has asked for the wisdom of the Perl Monks concerning the following question:

I'm in the unfort situation where i have a web interface and a link that will execute a heavy and long query.

What I dont want is the user to double click the link, or click many times if the query doesnt return "fast enuff"

I've got some ideas for a locking mechanism, however I'm also after any idea's/experience others may have.

Replies are listed 'Best First'.
Re: CGI and locking
by rob_au (Abbot) on May 15, 2002 at 09:56 UTC
Re: CGI and locking
by zakb (Pilgrim) on May 15, 2002 at 12:05 UTC

    You can do this reasonably reliably client-side with Javascript too...

    I've written the below from memory, I have used something similar in the past for exactly this situation...

    <script language="javascript"> var submitCount = 0; function doSubmit() { if (submitCount == 0) { submitCount++; document.form1.submit(); } else { alert("Please wait, lengthy query executing..."); } } </script> ... <form name=...> ... <input type="button" onClick="doSubmit();"> </form> ...
    Update: andye beat me to it! This approach will only work if your clients have Javascript enabled.
Re: CGI and locking
by andye (Curate) on May 15, 2002 at 11:59 UTC
    One neat trick: use Javascript to deactivate the submit button on form submit.

    Obviously you need to do something on the server-side as well - because not everyone has Javascript switched on - but this method provides immediate feedback to (most) users and prevents them from even trying to double-submit.

    hth,
    andy.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://166677]
Approved by rob_au
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others musing on the Monastery: (6)
As of 2024-03-28 14:05 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found