spacer
Yehuda Shiran February 1, 2002
Preventing Double Payments
Tips: February 2002

Yehuda Shiran, Ph.D.
Doc JavaScript

Developer News
Microsoft Shows Off Silverlight 4, IE9 Plans
Metasploit Expands Vulnerability Test Framework
HyperCard Reborn?

One of the problems in e-commerce is how to protect the user from making mistakes. It's even more critical when your protection target is on-line payments. Usually, you need to send a request to a credit authorization system, get back a transaction number, and only then charge the user's bank account. A common scenario is that the credit authorization number is late to come back, the user becomes anxious, and he or she presses the Charge My Account button again.

One way to protect the user is by disabling the tempting button after the user clicks it. Here is the button first:

Try it. See how the button gets disabled after you click it. Refresh the page to enable it again. The assumption here is that the authorization number will arrive by the time the user refreshes his or her window. Here is how the above button is defined:

  <BUTTON ID="tuition" 
    onclick="javascript:document.getElementById('tuition').disabled=true">Charge
    My Account!</BUTTON>
Notice the JavaScript statement that disables the button:

  document.getElementById('tuition').disabled = true
This tip works for IE and N6.


People who read this tip also read these tips:

Look for similar tips by subject:

internet.commediabistro.comJusttechjobs.comGraphics.com

Search:

WebMediaBrands Corporate Info

Legal Notices, Licensing, Permissions, Privacy Policy.
Advertise | Newsletters | Shopping | E-mail Offers | Freelance Jobs

webref The latest from WebReference.com Browse >
Rolling Out Your Own HTML Application Version Control · HTML 5: Client-side Storage · Working with Ajax Server Extensions
Sitemap · Experts · Tools · Services · Email a Colleague · Contact FREE Newsletters 
 The latest from internet.com
Wi-Fi Product Watch, November 2009 · Chip Market Recovering From '08 Collapse · Low-Cost Tools to Kickstart Your New Business