submit button grayed out to stop submitted twice

When a user submits direct payments from my website to paypal some times it can take a few seconds to process before it proceeds to the confirmation page.

Does anyone solutions to do the following...

1) A pop up message say your order is being processed till the page redirects to the confirmation page.

2) Gray out the submit button / image so the user will not be able to click the button again if they are being impatient?

I would also be interested in other suggestions? Thanks
petewinterAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

sandeshjCommented:
In javascript you could put a code something like this...

onclick="this.style.cursor = 'wait'; this.disabled=true;  this.form.submit()"

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
sandeshjCommented:
Sorry should have described what happens above.
I've re pasted the complete code for the image button.

On click the mouse cursor changes to waiting icon,
The button will be disabled.
The pressed button will stay as it is, it wouldn't go back to the release(original) icon...
<input name="someting" type="image" src="ProperButtonImage.gif" alt="Click to place order" value="SomeValue" onclick="this.style.cursor = 'wait'; this.disabled=true;  this.form.submit()"
                  onmouseover="this.src='OnClickButtonImage.gif'"
onmouseout="this.src='ProperButtonImage.gif'">

Open in new window

0
StealthyDevCommented:
Hi,

You should use a Synchronous AJAX call for this.

As soon as you get the control to your function (before calling AJAX page), disable the button using the code by sandeshj (above post).
After you get the response, set the button to enabled (if required, or move to next action, hopefully, message box saying failure/success).

Regards
buttonObject.disabled=true;
//place ajax call here

//after you get the response
buttonObject.disabled=false; // if required

Open in new window

0
StealthyDevCommented:
Hi again,

Since you have asked for other interesting suggesion, i would talk about JQuery. (Interesting, isn't it?)

Please find the below code, which is much easier to work with AJAX.

P.S:
You can download JQuery from:
http://jquery.com/


<script type="text/javascript" src="jquery-1.4.2.min.js"></script>

<input type=button onclick="pay()" id="btn" value="pay">

<script>

	function pay()
	{
		$("#btn").attr("disabled", true);
		$.post('myajax.html', '123', function(ress){
			alert(ress); // ress is the result from the ajax page
		});
	$("#btn").attr("disabled", false);
	$("#btn").attr("value", "pay again :)");
	}

</script>

Open in new window

0
petewinterAuthor Commented:
Many Thanks
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
PHP

From novice to tech pro — start learning today.