a simple server side trap:
when the submit button is hit, then a user variable is assigned ...
user$submitted .. and if that user submit a second time, it's
detected and they are given a 'please be patient' screen. when the
order is all processed up and the "thank you" screen given, then kill
the user$submitted variable.
I have client and server-side traps and create a transaction when
creating a new completed order to prevent simultaneous transactions
from stepping on each other. Nevertheless, once in a blue moon, I see
duplicate transactions - exact same order several seconds apart,
indicating the user was able to submit twice. At least on those
cases, it's very clear what happened and orders don't step on each
other.
On Feb 11, 2007, at 8:18 AM, Scott Cadillac wrote:
In my opinion, the best way is always a server-side solution where
you have
a pre-defined unique key for an insert, and you conditionally check
it if
exists in your database before the insert - because if it does,
then do an
Update, else the Insert.
Or if relying on client-side scripting, then ALWAYS use the
"onsubmit" of
the <FORM> tag and never the "onclick" of the input button.
Because for certain browsers, if the cursor is in a text field
(regardless
if a submit button is present or disabled) sometimes a simply hit
of the
keyboard ENTER key will trigger the form submit.
Whereas, the onsubmit event will stop the submit regardless of how
it was
fired, something like so:
var globalVarCheck = false;
function checkSubmit(){
document.getElementById('theButton').disabled = true;
document.getElementById('theButton').value = 'Please stand by...';
if(globalVarCheck == false){
globalVarCheck = true;
return true;
}else{
return false;
}
}
<form method="post" onsubmit="return checkSubmit();">
<input type="text" name="field1" value="">
<input type="submit" id="theButton" value="Submit">
</form>
Hope that helps.
~~~~~~~~~~~~~~~~~~~~
Scott Cadillac
(403) 254-5002
[EMAIL PROTECTED]
XML-Extranet
P.O. Box 69006
RPO Bridlewood SW
Calgary, Alberta
Canada T2Y 4T9
http://www.xmlx.net/
~~~~~~~~~~~~~~~~~~~~
-----Original Message-----
From: Alan Wolfe [mailto:[EMAIL PROTECTED]
Sent: Sunday, February 11, 2007 9:08 AM
To: [email protected]
Subject: Re: Witango-Talk: Preventing two order submits
Believe it or not Roland you can do it this way too (:
<input type="submit" value="Click Me"
onclick="this.style.visility='hidden';this.style.display='none';">
On 2/10/07, Roland Dumas <[EMAIL PROTECTED]> wrote:
On Feb 10, 2007, at 1:40 PM, Dan Stein wrote:
More investigation seems like what happens is since I don't go
through the
DB and mark those cart items as having been inserted into our FMP
database
right away it is possible for them if the hit the button that close
together
that it will see the items in the cart again and I guess add them
to the
request scope cart. I am still a little fuzzy on this.
But if I make the submit button go away will that take care of
this? Can you
point me to a place where I can get that code?
<div id=submitWrapper style="display: block;"><input type=submit
value=submit onClick="document.getElementById
('submitWrapper').style.display = 'none'"></div>
It looks like I could move the cleanup cart routine to right under
insert
order items or maybe even above it. Would that work and could it
have any
other effect we did not want?
--
____________________________________________________________________
____
TO UNSUBSCRIBE: Go to http://www.witango.com/developer/maillist.taf
_____________________________________________________________________
___
TO UNSUBSCRIBE: Go to http://www.witango.com/developer/maillist.taf
______________________________________________________________________
__
TO UNSUBSCRIBE: Go to http://www.witango.com/developer/maillist.taf
________________________________________________________________________
TO UNSUBSCRIBE: Go to http://www.witango.com/developer/maillist.taf