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 Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Double-sumbit prevention

Status
Not open for further replies.

aharrisreid

Programmer
Nov 17, 2000
312
GB

On an order form, I would like to ensure that users who accidentally double-click on a submit button do not create two orders.

I have tried disabling the button by placing onclick="document.thisform.buttonname.disable" in the button definition. This disables the button but does not submit the form. I still want the form submitted, but only on the first click.

Any help would be appreciated.

Alan
 
You can check on the server-side to make sure that a duplicate order hasn't been placed in the last 5 minutes. As for the button, try this...

<script>
function subOrder(){
document.myForm.orderButton.disabled = true
document.myForm.submit()
}
</script>
<form name=&quot;myForm&quot; action=&quot;myAction.asp&quot; method=&quot;post&quot;>
...
...
<input type=button onClick=&quot;subOrder()&quot; name=&quot;orderButton&quot; value=&quot;Place Order&quot;>
</form> Get the Best Answers! faq333-2924
Is this an asp FAQ? faq333-3048
Tek-Tips Best Practices: FAQ183-3179
 
mwolf00

>> document.myForm.orderButton.disabled = true
document.myForm.submit()
<<

Great solution, many thanks.

Alan
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top