?
Solved

How to "idiot proof" submit buttons against a DOUBLE CLICK

Posted on 2013-01-23
16
Medium Priority
?
283 Views
Last Modified: 2013-02-01
I have an application which is working perfectly, except in one section where a DOUBLE sale in recorded in the database if the SUBMIT button is double clicked, instead of single click. Apart from putting a warning note beside the button, is there a more elegant fix ?

Thanks very much in advance

Notes on environment

Windows 7
Dreamweaver dev env
Coldfusion
MS Access for data repository use only (no programming)
0
Comment
Question by:jameskane
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 6
  • 5
  • 2
  • +1
16 Comments
 
LVL 28

Expert Comment

by:burrcm
ID: 38809473
Don't know the system, but perhaps a check for duplicates as part of the onclick code? I could do this in Access easily....

Chris B
0
 

Author Comment

by:jameskane
ID: 38809581
Had a look Chris, but don't think the problem is there. The submit button simply sends data via a form to the database -  can(t see any duplication errors
0
 
LVL 28

Expert Comment

by:burrcm
ID: 38809622
OK. You did imply I think that two clicks = two entries, so a check for same seemed reasonable. Out of my depth here. Can you prevent / mask a double click by setting some timer event on a click? Just throwing out ideas.....

Chris B
0
Is Your Team Achieving Their Full Potential?

74% of employees feel they are not achieving their full potential. With Linux Academy, not only will you strengthen your team's core competencies but also their knowledge of of the newest IT topics.

With new material every week, we'll make sure that you stay ahead of the game.

 
LVL 15

Expert Comment

by:Tomarse111
ID: 38809656
You could disable the submit button onClick ?

or set a session value to check against its existence. If it exists then don't allow the second submit?

Let me know if that's up the right alley and I will help if I can

Tom
0
 

Author Comment

by:jameskane
ID: 38809662
I think what's needed is some sort of java code to be wrapped around the button which causes all clicks to be subpressed apart from the first one. Easier said than done I'm sure !!
Thanks Chris for taking time to look at this

jim
0
 

Author Comment

by:jameskane
ID: 38809714
This is the code around the submit button, which has the name "PAYER MAINTENANT"              

<td colspan="2" align="center"><input type="submit" name="pay" id="Pay" value="Payer Maintenant" />
      <input name="deltacumcost" type="hidden" id="deltacumcost" value="<cfoutput>#form.deltacumcost#</cfoutput>" />
      <input name="YTDpurchases" type="hidden" id="YTDpurchases" value="<cfoutput>#form.cumcost#</cfoutput>" />
      <input name="cost_libre" type="hidden" id="cost_libre" value="<CFOUTPUT>#cost_libre#</CFOUTPUT>" />
      <input name="cost_enroll" type="hidden" id="cost_enroll" value="<CFOUTPUT>#cost_enroll#</CFOUTPUT>" />
      <input name="memberID" type="hidden" id="memberID" value="<cfoutput>#session.memberID#</cfoutput>" />
      <input name="adjustments" type="hidden" id="adjustments" value="0" />
      <input name="owed" type="hidden" id="owed" value="<cfoutput> #owed# </cfoutput>" />
      <input name="positivedeltacumcost" type="hidden" id="positivedeltacumcost" value="<cfoutput> #positivedeltacumcost# </cfoutput>" /></td>
  </tr>
</table>
</form>
0
 
LVL 15

Assisted Solution

by:Tomarse111
Tomarse111 earned 1000 total points
ID: 38809760
OK, so is your submit button a simple HTML <input type="submit"> ? If so:

<form action="" method="post">
	<input type="submit" value="OK" onClick="this.disabled=true;">
</form>

Open in new window


Should work for you
0
 

Author Comment

by:jameskane
ID: 38810415
Many thanks for taking time. This worked for the first sale to the person -  I double clicked the button and did not get a doubling of the sale. However, on running another transaction, it
seems like the botton is not working. It appears to work - but the actual sale does not get reported. Looks like I disabled the submit button with the first double click and it did not come back on again  - my code is below.

<tr align="left">
    <td colspan="2" align="center"><input type="submit" name="pay" id="Pay" value="Payer Maintenant" onClick="this.disabled=true;"/>
0
 
LVL 15

Expert Comment

by:Tomarse111
ID: 38810534
Does your submit button post a form? as in does the page refresh upon itself? This could be a caching thing.

But you could force it to be not disabled on its return by adding the following into the body tag:

<body onLoad="document.getElementById('Pay').disabled=false;">

Open in new window

0
 

Accepted Solution

by:
jameskane earned 0 total points
ID: 38810663
Hi  Tomarse111,

seems to be working with the following - what you gave me, plus the addition of  this.form.submit();  

onClick="this.disabled=true;this.form.submit();"

Need to do some more testing on it -  

Wondering if I need the body tag additioon ??
0
 
LVL 15

Expert Comment

by:Tomarse111
ID: 38810706
The addition of the forced submit, should do the job as well :)
0
 
LVL 36

Expert Comment

by:SidFishes
ID: 38810744
Personally, I think the client side approach is a bad idea. (In general, don't trust anything from the client side,...ever)

What I do at the end of my checkout process is expire a session variable cartid

pseudo code

<cfif cartid neq "">
<cfquery>    
insert order into db
</cfquery>
    <cfset session.cartid = "">
<cfelse>
<div> Order already submitted</div>
<cfabort>
</cfif>

I actually send some ajax back rather than use the abort but that's the basic idea.
0
 

Author Comment

by:jameskane
ID: 38824172
I've requested that this question be closed as follows:

Accepted answer: 250 points for Tomarse111's comment #a38809760
Assisted answer: 0 points for jameskane's comment #a38810663

for the following reason:

Thanks everyone for taking time to look at this. i got the solution mostly from you Tomarse111 -  it put me in the right direction, but was't turn key.<br /><br />Also, thanks for the input SidFishes - got to keep that point in mind for the future.
0
 
LVL 15

Expert Comment

by:Tomarse111
ID: 38824173
Hi

As stated by the question asker in both his comments and reason for closing, my solution is what he used in the end, therefore i would assume either i get full points or at the very least an assist (by definition; i assisted him in completing his objective).

As ever i will bow to the moderators decision

Many thanks

Tom
0

Featured Post

Docker-Compose to Simplify Multi-Container Builds

Our veteran DevOps Author takes you through how to build a multi-container environment, managed with a single utility in order to simplify your deployments.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The technique is by far very Simple! How we can export the ColdFusion query results to DOC file?  Well before writing this I researched a lot in Internet but did not found a good Answer anyways!  So i thought now i should share my small snippet w…
I spent nearly three days trying to figure out how incorporate OAuth in Coldfusion for the Eventful API. Hopefully, this article will allow Coldfusion Programmers to buzz through the API when they need to. Basically, what this script does is authori…
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…
We’ve all felt that sense of false security before—locking down external access to a database or component and feeling like we’ve done all we need to do to secure company data. But that feeling is fleeting. Attacks these days can happen in many w…

719 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question