Reply
javascript - stop double clicking of button - desperate need of help
Old 11-21-2006, 04:45 PM javascript - stop double clicking of button - desperate need of help
Novice Talker

Posts: 8
Hi
I have an oscommerce site, but I need some help.
I have a problem with customers clicking the confirm order button twice, which then duplicates there order.
I have put in big letters
PLEASE CLICK THIS BUTTON ONCE but that doesnt work, they still double click
I got some javascript that is supposed to stop the button being clicked twice, but it doesn't work.
Can anyone give me some code that does work, or something that changes the button message to ..... processing please wait, or something similer
I have put the code below, where the button is, but Im not a programmer so not sure what I would need to change.
PHP Code:
<?php if (isset($$payment->form_action_url)) {
    
$form_action_url = $$payment->form_action_url;
  } else {
    
$form_action_url tep_href_link(FILENAME_CHECKOUT_PROCESS'''SSL');
  }
  echo 
tep_draw_form('checkout_confirmation'$form_action_url'post');
the code that doesnt work is this
[php]<script language="JavaScript">
<!--
var 
_submitted false;
validate = function () { 
_submitted = ( ! _submitted ) ? true true 
if ( 
_submitted document.getElementById"checkout_confirmation" ).submit() ;
}
-->
</script>
echo tep_image_submit('button_confirm_order.gif', IMAGE_BUTTON_CONFIRM_ORDER, ' onClick="validate();" ') . '</form>' . "\n";
if (is_array($payment_modules->modules)) {
echo $payment_modules->process_button();
}
echo tep_image_submit('button_confirm_order.gif', IMAGE_BUTTON_CONFIRM_ORDER) . '</form>' . "\n";
?>[/php]

I am absolutly desperate, so any help would be great
ronnieb is offline
Reply With Quote
View Public Profile
 
When You Register, These Ads Go Away!
Old 11-21-2006, 08:32 PM Re: javascript - stop double clicking of button - desperate need of help
mgraphic's Avatar
Truth Seeker

Latest Blog Post:
Wireless Audio
Posts: 2,320
Name: Keith Marshall
Location: West Hartford, CT
If you add the this.disabled=true; at the front of the onclick attribute and this.form.submit(); at the end, it will use js to disable the button once clicked as the form is submitting.

PHP Code:
echo tep_image_submit('button_confirm_order.gif'IMAGE_BUTTON_CONFIRM_ORDER' onclick="this.disabled=true;validate();this.form.submit();" ') . '</form>' "\n"
__________________

<mgraphic /> - I don't have a solution but I admire the problem.
mgraphic is offline
Reply With Quote
View Public Profile
 
Old 11-22-2006, 03:39 AM Re: javascript - stop double clicking of button - desperate need of help
Novice Talker

Posts: 8
Hi
inserted this line in the code

PHP Code:
echo tep_image_submit('button_confirm_order.gif'IMAGE_BUTTON_CONFIRM_ORDER' onclick="this.disabled=true;validate();this.form.submit();" ') . '</form>' "\n"

that seems to prevent the button being clicked at all,
any advice

thanks
ronnieb is offline
Reply With Quote
View Public Profile
 
Old 11-22-2006, 10:10 AM Re: javascript - stop double clicking of button - desperate need of help
ADAM Web Design's Avatar
Canadastaninianite

Posts: 5,945
Name: Adam for web page design, not program
Location: Toronto, Ontario, Canada
Try putting an onsubmit handler in your <form> tag.

<form onsubmit="document.getElementById('submit-button').disabled = true;">
...
<input type="submit" id="submit-button" ...
ADAM Web Design is offline
Reply With Quote
View Public Profile Visit ADAM Web Design's homepage!
 
Old 11-22-2006, 11:09 AM Re: javascript - stop double clicking of button - desperate need of help
Novice Talker

Posts: 8
sorry ... not a programmer as i said


does this make this

<form onsubmit="document.getElementById('submit-button').disabled = true;">

echo tep_image_submit('button_confirm_order.gif', IMAGE_BUTTON_CONFIRM_ORDER) . '</form>' . "\n";

<input type="submit" id="submit-button"

because that gives me a parse error

this is the script it needs to go in

PHP Code:
if (is_array($payment_modules->modules)) {
    echo 
$payment_modules->process_button();
  }
    echo 
tep_image_submit('button_confirm_order.gif'IMAGE_BUTTON_CONFIRM_ORDER) . '</form>' "\n";
?> 
sorry to be so dense

thanks
ronnieb is offline
Reply With Quote
View Public Profile
 
Old 11-23-2006, 04:03 AM Re: javascript - stop double clicking of button - desperate need of help
Novice Talker

Posts: 8
bump - please
ronnieb is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to javascript - stop double clicking of button - desperate need of help
 

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off




   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML

 


Page generated in 0.14102 seconds with 12 queries