[ic] Disable "Place Order" button after clicked

Kevin Old interchange-users@icdevgroup.org
Thu May 8 11:26:01 2003


On Thu, 2003-05-08 at 10:23, Kevin Old wrote:
> Hello everyone,
> 
> I have had several orders that have been submitted twice in the past few
> days, due to users double-clicking on the "Place Order" button.
> 
> I know how to accomplish this with javascript and have tried to combine
> that with the "confirm" parameter for the button tag, but my tag ends up
> looking like this:
> 
> <input TYPE="submit" NAME="mv_click" VALUE="Place Order" onclick="return
> confirm('javascript: mv_click.disabled==true;')">

Well, after playing with this for a while, I've figured out a way, but
welcome any other suggestions.

Here's the JS function:

button1 = new Image();
   button1.src = "/em/images/one_moment_please_small.gif";
   var theForm;
   var requestSubmitted = false;
   function disableButton(btn,form,buttonType) {
alert("button is:" + btn)
if (!requestSubmitted){
        if (buttonType != null) {
           var buttonName = buttonType;
           btn.src = buttonName.src; // image swap happens here
        }
        theForm = form
        btn.disabled = true;
        } else {
        return false;
        }
  } 

And the code for the submit button:

 <input type="hidden" name="mv_todo" value="submit">
 <INPUT TYPE=image VALUE="Place Order" name="mv_click"
src="__THEME_IMG_DIR__placeorder.gif" border=0 onclick="javascript:
return disableButton(this,checkout,button1)">

FYI, I got the one_moment_please_small.gif from netflix.com's sign in
page.  If you click on the red "Sign In" button it will change to a "One
Moment Please...." image.  View the source for where to download the
image.

Hope this helps others,
Kevin

-- 
Kevin Old <kold@carolina.rr.com>