Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Preventing form submission twice by doublclicking the submit button 1

Status
Not open for further replies.

cshncn

Programmer
Jan 14, 2003
11
US
Hi,

Just wondering if ColdFusion has anything to prevent form submission twice when user doubleclicks the submit button. I know Javascript can do the work. But I want to know if there is any server sider solution for this. Thanks.
 
Hi cshncn,

I usually have a session marker variable set. When the user hits Submit, the action template checks for the existence of the variable, and then whacks the variable. Subsequent calls to the action template won't find the session variable, so the database action doesn't take place, and the user is redirected to a "Sorry, you already did this" page.

HTH,

Phil Hegedusich
Senior Web Developer
IIMAK
-----------
Boy howdy, my Liberal Studies degree really prepared me for this....
 
Thank Phil. I tried the session variable control. It works for click twice with an interval, but when I doubleclick, the action page is still executed twice. I guess the session control on the server is not fast enough to capture the doubleclick and stop the second form submission?

cshncn
 
lets see your form/ javascript and submit code...

------------------------------------------------------------------------------
brannonH
if( !succeed ) try( );
 
Maybe it's also possible to set a session variable if the user clicks the send button.

If he sends it twice in a difined timspan, you can give the user a error message....

Good Luck, Mike

Some people can learn, some people can teach.
 
I think you better stick to the JS solution. You don't have to complicate things ;)

<CFSharedFolder Permissions="rw"></CFSharedFolder>
 
javascript is the best for this. you want to be able to prevent the form from being submitted twice from the CLIENT side of things.

 
in your submit button add

onclick="this.disabled=true;"

Human beings, who are almost unique in having the ability to learn from the experience of others, are also remarkable for their apparent disinclination to do so.
-Douglas Adams (1959-2001)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top