Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

JavaScript Forum


You are currently viewing our JavaScript Forum as a guest. Please register to participate.
Login



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

Posts: 17
Trades: 0
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
 
 
Register now for full access!
Old 11-21-2006, 09:32 PM Re: javascript - stop double clicking of button - desperate need of help
mgraphic's Avatar
Truth Seeker

Latest Blog Post:
JAMISONTUNES
Posts: 2,898
Name: Keith Marshall
Location: Connecticut
Trades: 0
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, 04:39 AM Re: javascript - stop double clicking of button - desperate need of help
Average Talker

Posts: 17
Trades: 0
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, 11:10 AM Re: javascript - stop double clicking of button - desperate need of help
ADAM Web Design's Avatar
Canadastaninianite

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

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

Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
(my blog)


Please login or register to view this content. Registration is FREE
(with proof)
ADAM Web Design is offline
Reply With Quote
View Public Profile Visit ADAM Web Design's homepage!
 
Old 11-22-2006, 12:09 PM Re: javascript - stop double clicking of button - desperate need of help
Average Talker

Posts: 17
Trades: 0
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, 05:03 AM Re: javascript - stop double clicking of button - desperate need of help
Average Talker

Posts: 17
Trades: 0
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 Search this Thread
Search this Thread:

Advanced Search

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

BB 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.27538 seconds with 12 queries