Re: Submit Once
Gang, I am occasionally getting duplicate records in my database. I think it is coming from people hitting “Submit” twice when the server is slow. How do you guys prevent this? I tried some JavaScript code to disable the button, which did gray-out the button, but then did not pass the Button info along to Cold Fusion. Jeff, Her's what I use, while not a complete solution, it works for most browsers if Javascript is turned on: input type=button value=Update Cart onClick=if(this.value == 'Update Cart') this.form.submit(); this.value = 'Please Wait'; This button will only submit the form if the displayed value is Update Cart. hth, larry ~| Logware (www.logware.us): a new and convenient web-based time tracking application. Start tracking and documenting hours spent on a project or with a client with Logware today. Try it for free with a 15 day trial account. http://www.houseoffusion.com/banners/view.cfm?bannerid=67 Message: http://www.houseoffusion.com/lists.cfm/link=i:4:201581 Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/4 Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4 Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4 Donations Support: http://www.houseoffusion.com/tiny.cfm/54
Re: Submit Once
Just to augment Larry's suggestion, when you go to actually input the record into the database, it might not be a bad idea to incorporate some sort of duplicate check here as well. The easiest way to do this is to enforce unique key constraints in the database, then code using TRY/CATCH to trap for this error. A less desirable method would be to run a query first to see if the record about to be submitted looks like a duplicate. Gang, I am occasionally getting duplicate records in my database. I think it is coming from people hitting â?oSubmitâ? twice when the server is slow. How do you guys prevent this? I tried some JavaScript code to disable the button, which did gray-out the button, but then did not pass the Button info along to Cold Fusion. Jeff, Her's what I use, while not a complete solution, it works for most browsers if Javascript is turned on: input type=button value=Update Cart onClick=if(this.value == 'Update Cart') this.form.submit(); this.value = 'Please Wait'; This button will only submit the form if the displayed value is Update Cart. hth, larry ~| Find out how CFTicket can increase your company's customer support efficiency by 100% http://www.houseoffusion.com/banners/view.cfm?bannerid=49 Message: http://www.houseoffusion.com/lists.cfm/link=i:4:201586 Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/4 Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4 Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4 Donations Support: http://www.houseoffusion.com/tiny.cfm/54
Submit Once
Gang, I am occasionally getting duplicate records in my database. I think it is coming from people hitting “Submit” twice when the server is slow. How do you guys prevent this? I tried some JavaScript code to disable the button, which did gray-out the button, but then did not pass the Button info along to Cold Fusion. Thanks for you help, Jeff ~| Discover CFTicket - The leading ColdFusion Help Desk and Trouble Ticket application http://www.houseoffusion.com/banners/view.cfm?bannerid=48 Message: http://www.houseoffusion.com/lists.cfm/link=i:4:201395 Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/4 Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4 Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4 Donations Support: http://www.houseoffusion.com/tiny.cfm/54
Re: Submit Once
i don't know of an easy way. but one thing you could do is to compare the data with what is already in the DB and if it matches then don't do the second input. It will really depend on the type of data being input and if there are any unique fields you can compare to (like email address's etc). jonese On Apr 4, 2005 1:09 PM, Jeffrey Pratte [EMAIL PROTECTED] wrote: Gang, I am occasionally getting duplicate records in my database. I think it is coming from people hitting “Submit†twice when the server is slow. How do you guys prevent this? I tried some JavaScript code to disable the button, which did gray-out the button, but then did not pass the Button info along to Cold Fusion. Thanks for you help, Jeff ~| Discover CFTicket - The leading ColdFusion Help Desk and Trouble Ticket application http://www.houseoffusion.com/banners/view.cfm?bannerid=48 Message: http://www.houseoffusion.com/lists.cfm/link=i:4:201398 Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/4 Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4 Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4 Donations Support: http://www.houseoffusion.com/tiny.cfm/54
Re: Submit Once
Jeffrey Pratte wrote: Gang, I am occasionally getting duplicate records in my database. I think it is coming from people hitting “Submit” twice when the server is slow. How do you guys prevent this? I tried some JavaScript code to disable the button, which did gray-out the button, but then did not pass the Button info along to Cold Fusion. Thanks for you help, Jeff There's a few ways. The simplest I can think of is to create a data structure (a database table would be sufficent) to keep track of your forms where you want to prevent multiple submissions. The schema of a table to do this would be something like the following: CREATE TABLE forms (uuid CHAR(35) NOT NULL PRIMARY KEY); Before you generate a form, do the following: cfset uuid = CreateUUID() cfquery name=foo datasource=bar INSERT INTO forms ( uuid ) VALUES ( cfqueryparam cfsqltype=CF_SQL_CHAR value=#uuid# ) /cfquery And then embed the uuid in a hidden field in the form you want to protect. Just before you process the form, check to see if the uuid is in the table. If it is, it's the first time the form has been processed, otherwise it's a resubmit. cfquery name=checkUUID datasource=bar SELECT COUNT(*) AS isPresent FROMforms WHERE uuid = cfqueryparam cfsqltype=CF_SQL_CHAR value=#FORM.uuid# /cfquery cfif checkUUID.isPresent cfquery name=foo datasource=bar DELETE FROM forms WHERE uuid = cfqueryparam cfsqltype=CF_SQL_CHAR value=#FORM.uuid# /cfquery !--- Process as normal --- cfelse !--- It's a resubmit --- /cfif Now, where is a chance of a race condition in the code above where, if the user was quick enough on the resubmit (and they'd have to be *really* quick), the code to check if the form was present might be ran in one of the requests before the first one managed to delete it. To prevent this, you'd have to serialise access to the forms tables somehow, be it through a transaction or an exclusive table lock. But the principle is sound and should work for you. K. ~| Logware (www.logware.us): a new and convenient web-based time tracking application. Start tracking and documenting hours spent on a project or with a client with Logware today. Try it for free with a 15 day trial account. http://www.houseoffusion.com/banners/view.cfm?bannerid=67 Message: http://www.houseoffusion.com/lists.cfm/link=i:4:201399 Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/4 Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4 Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4 Donations Support: http://www.houseoffusion.com/tiny.cfm/54
Re: Submit Once
Gang, I am occasionally getting duplicate records in my database. I think it is coming from people hitting “Submit” twice when the server is slow. How do you guys prevent this? I tried some JavaScript code to disable the button, which did gray-out the button, but then did not pass the Button info along to Cold Fusion. Thanks for you help, Jeff Well the simplest solution looks like this: script language=JavaScript function submitForm(frm) { if (typeof frm._submitted == undefined) { frm._submitted = true; return true; } else { return false; } } /script form onsubmit=return submitForm(this); qForms and the onTap framework both have some more sophisticated solutions which ultimately use the same technique. hth s. isaac dealey 954.522.6080 new epoch : isn't it time for a change? add features without fixtures with the onTap open source framework http://macromedia.breezecentral.com/p49777853/ http://www.sys-con.com/author/?id=4806 http://www.fusiontap.com ~| Find out how CFTicket can increase your company's customer support efficiency by 100% http://www.houseoffusion.com/banners/view.cfm?bannerid=49 Message: http://www.houseoffusion.com/lists.cfm/link=i:4:201400 Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/4 Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4 Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4 Donations Support: http://www.houseoffusion.com/tiny.cfm/54
Re: Submit Once
Also, you might be interested in this post on Mark Nottingham's site: http://www.mnot.net/blog/2003/09/13/click_submit_only_once K. ~| Logware (www.logware.us): a new and convenient web-based time tracking application. Start tracking and documenting hours spent on a project or with a client with Logware today. Try it for free with a 15 day trial account. http://www.houseoffusion.com/banners/view.cfm?bannerid=67 Message: http://www.houseoffusion.com/lists.cfm/link=i:4:201403 Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/4 Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4 Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4 Donations Support: http://www.houseoffusion.com/tiny.cfm/54
Re: Submit Once
Keith Gaughan wrote: But the principle is sound and should work for you. This also has the advantage that it ensure that the form works without the browser needing to have JavaScript enabled. K. ~| Logware (www.logware.us): a new and convenient web-based time tracking application. Start tracking and documenting hours spent on a project or with a client with Logware today. Try it for free with a 15 day trial account. http://www.houseoffusion.com/banners/view.cfm?bannerid=67 Message: http://www.houseoffusion.com/lists.cfm/link=i:4:201404 Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/4 Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4 Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4 Donations Support: http://www.houseoffusion.com/tiny.cfm/54
Re: Submit Once
Jeffrey Pratte wrote: Gang, I am occasionally getting duplicate records in my database. I think it is coming from people hitting “Submit” twice when the server is slow. How do you guys prevent this? I tried some JavaScript code to disable the button, which did gray-out the button, but then did not pass the Button info along to Cold Fusion. Thanks for you help, Jeff There's a few ways. The simplest I can think of is to create a data structure (a database table would be sufficent) to keep track of your forms where you want to prevent multiple submissions. That's actually a pretty complicated solution -- although if you need a solution that works server-side without the aid of javascript you're reather limited to something like that... I wonder if visually impaired users double-click form submit buttons the same as some sighted users... I wouldn't expect it, though it could happen. In general I wouldn't expect users who have javascript-disabled (either due to visual impairment or otherwise) to produce those impatient double-submits. s. isaac dealey 954.522.6080 new epoch : isn't it time for a change? add features without fixtures with the onTap open source framework http://macromedia.breezecentral.com/p49777853/ http://www.sys-con.com/author/?id=4806 http://www.fusiontap.com ~| Logware (www.logware.us): a new and convenient web-based time tracking application. Start tracking and documenting hours spent on a project or with a client with Logware today. Try it for free with a 15 day trial account. http://www.houseoffusion.com/banners/view.cfm?bannerid=67 Message: http://www.houseoffusion.com/lists.cfm/link=i:4:201405 Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/4 Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4 Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4 Donations Support: http://www.houseoffusion.com/tiny.cfm/54
re: Submit Once
If you are using cfmx 7 and cfform you can add validate=submitonce to your submit button. (see below) cfinput name=submit value=Submit type=submit label=Submit validate=submitonce / From: Jeffrey Pratte [EMAIL PROTECTED] Sent: Monday, April 04, 2005 1:11 PM To: CF-Talk cf-talk@houseoffusion.com Subject: Submit Once Gang, I am occasionally getting duplicate records in my database. I think it is coming from people hitting â?oSubmitâ? twice when the server is slow. How do you guys prevent this? I tried some JavaScript code to disable the button, which did gray-out the button, but then did not pass the Button info along to Cold Fusion. Thanks for you help, Jeff ~| Discover CFTicket - The leading ColdFusion Help Desk and Trouble Ticket application http://www.houseoffusion.com/banners/view.cfm?bannerid=48 Message: http://www.houseoffusion.com/lists.cfm/link=i:4:201407 Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/4 Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4 Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4 Donations Support: http://www.houseoffusion.com/tiny.cfm/54
Re: Submit Once
S.Isaac Dealey wrote: That's actually a pretty complicated solution -- although if you need a solution that works server-side without the aid of javascript you're reather limited to something like that... If you looking for a server-side only solution, it's the simplest. Mind you, if you don't mind using JS, then there are, of course, simpler ways. But I'd taken from his post--and I might be mistaken--that those weren't what he was looking for. No matter though. I wonder if visually impaired users double-click form submit buttons the same as some sighted users... I wouldn't expect it, though it could happen. In general I wouldn't expect users who have javascript-disabled (either due to visual impairment or otherwise) to produce those impatient double-submits. I'm not even thinking of them! I was just presenting a server-side only solution. BTW, you could also use a struct stored in some persistent scope such as SESSION or APPLICATION as a set and you'd get the same effect. I do this in a replacement for cfform I wrote that uses more modern validation and has a few extra features. K. ~| Find out how CFTicket can increase your company's customer support efficiency by 100% http://www.houseoffusion.com/banners/view.cfm?bannerid=49 Message: http://www.houseoffusion.com/lists.cfm/link=i:4:201409 Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/4 Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4 Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4 Donations Support: http://www.houseoffusion.com/tiny.cfm/54