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

Yehuda Shiran, Ph.D.
Doc JavaScript

Developer News
News Flash: Adobe Has iPhone Workaround
Adobe's Flash 10.1 Goes Mobile (Minus iPhone)
A Salute to Visionary CEOs

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, Reprints, Permissions, Privacy Policy.
Advertise | Newsletters | Shopping | E-mail Offers | Freelance Jobs

webref The latest from WebReference.com Browse >
Building a Banking Application Home Page with OOP · Mixing Scripting Languages · Review: phpFox, a Social Networking CMS with all the Bells and Whistles
Sitemap · Experts · Tools · Services · Email a Colleague · Contact FREE Newsletters 
 The latest from internet.com
Enterprise 2.0: Social Networking in the Cloud · BroadSoft Marketplace Hastens Pace of Telephony Innovation · Review: HTC Hero for Sprint