[ic] Disable "Place Order" button after clicked

Joshua Lavin interchange-users@icdevgroup.org
Fri May 9 05:08:01 2003


On Thursday, May 8, 2003, at 10:25  AM, Kevin Old wrote:

> 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>

For now, I've changed my code to this (thanks, Kevin!), except removing 
the image swap, and using just a plain submit button.

Works fine, except any other "submits," such as removing an item, 
changing the country, or recalculating give "errors in your last 
submission...", just like my old code did.

Does it do this to you?

Josh