Replace submit button with animated gif on submit

Hello,

to stop people from clicking submit more than once on my order form and so that it looks cool :-) i'd like to replace the image that i currently use for my 'place order' button with a little animated gif and at the same time disable it so it cant be clicked again.
<input name="placeorder" type="image" src="images/gifs/placeorder_button.gif" alt="Click to place order" value="Place Order">

Open in new window

LVL 1
bede123Asked:
Who is Participating?
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.

leakim971PluritechnicianCommented:
Hello bede123 (Patrice ?),

Try :

(we add : onclick="placeorder();this.disabled=true;" : it will call placeorder function and, after, disable the button)
<input name="placeorder" type="image" src="images/gifs/placeorder_button.gif" alt="Click to place order" value="Place Order" onclick="placeorder();this.disabled=true;" />

Open in new window

0
bede123Author Commented:
but what about swapping the image?
0
sandeshjCommented:
Here you can get a diff image on hover of mouse. The mouse icon too changes to wait on click.
<input name="placeorder" type="image" src="images/gifs/placeorder_button.gif" alt="Click to place order" value="Place Order" onclick="this.style.cursor = 'wait'; this.disabled=true;  this.form.submit()"
                  onmouseover="this.src='images/gifs/placeorder_button2.gif'" 
onmouseout="this.src='images/gifs/placeorder_button.gif'">

Open in new window

0
Big Business Goals? Which KPIs Will Help You

The most successful MSPs rely on metrics – known as key performance indicators (KPIs) – for making informed decisions that help their businesses thrive, rather than just survive. This eBook provides an overview of the most important KPIs used by top MSPs.

bede123Author Commented:
thanks, but what i'm after is for the entire image to be swapped when clicked, not just the mouse
0
leakim971PluritechnicianCommented:
With the swap feature :

we add : this.src='images/gifs/placeorder_button2_disabled.gif';

onclick="placeorder();this.src='images/gifs/placeorder_button2_disabled.gif';this.disabled=true;"
<input name="placeorder" type="image" src="images/gifs/placeorder_button.gif" alt="Click to place order" value="Place Order" onclick="placeorder();this.src='images/gifs/placeorder_button2_disabled.gif';this.disabled=true;" />

Open in new window

0
bede123Author Commented:
i cant get this to work, when i click on it nothing changes. have you tested this?

0
leakim971PluritechnicianCommented:
yes, work fine !


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<script language="javascript">
	function placeorder() {
	}
</script>
</head>
<body>
<input name="placeorder" type="image" src="http://switchon.org.in/India/wp-content/uploads/2008/11/090023.jpg" alt="Click to place order" value="Place Order" onclick="placeorder();this.src='http://www.jtduoff.fr/IMG/cache-443x640/OFF_2009_logo_cprs-443x640.jpg';this.disabled=true;" />
</body>
</html>

Open in new window

0
bede123Author Commented:
ah yes i see, thanks but now whats happens is that the button doesnt actaully submit my form. no validation happens or anything!
0
leakim971PluritechnicianCommented:
Patrice I don't know, I want to give you what you ask, do I missed something ?
0
bede123Author Commented:
? i dont understand what you mean?


my problem is now that when i click to submnit my form it doesnt actually submit the form and no validation of the form takes place.
0
leakim971PluritechnicianCommented:
When you submit you form generally you stay on the same page without any reload ?
0
bede123Author Commented:
yes for validation, then if everything is ok it takes the customer so a confirmation page
0
leakim971PluritechnicianCommented:
if you want to submit a form where the button is or not use : document.forms['form_name'].submit(); or if you have only one form : document.forms[0].submit();


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<script language="javascript">
        function placeorder() {
        }
</script>
</head>
<body>
<form name="form_name" action="idontknow.php" method="POST" >
<input name="placeorder" type="image" src="http://switchon.org.in/India/wp-content/uploads/2008/11/090023.jpg" alt="Click to place order" value="Place Order" onclick="placeorder();this.src='http://www.jtduoff.fr/IMG/cache-443x640/OFF_2009_logo_cprs-443x640.jpg';this.disabled=true;document.forms['form_name'].submit();" />
</form>
</body>
</html>

Open in new window

0
leakim971PluritechnicianCommented:
or/and :


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<script language="javascript">
        function placeorder() {
        }
        function validateorder() {
           if(condition) // you need to elaborate yourslef your form validation
              return true;
           else
              return false;
        }
</script>
</head>
<body>
<form name="form_name" action="idontknow.php" method="POST" >
<input name="placeorder" type="image" src="http://switchon.org.in/India/wp-content/uploads/2008/11/090023.jpg" alt="Click to place order" value="Place Order" onclick="placeorder();this.src='http://www.jtduoff.fr/IMG/cache-443x640/OFF_2009_logo_cprs-443x640.jpg';this.disabled=true;document.forms['form_name'].submit();" />
</form>
</body>
</html>

Open in new window

0
leakim971PluritechnicianCommented:
correction
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<script language="javascript">
        function placeorder() {
        }
        function validateorder() {
           if(condition) // you need to elaborate yourslef your form validation
              return true;
           else
              return false;
        }
</script>
</head>
<body>
<form name="form_name" action="idontknow.php" method="POST" onsubmit="return validateorder();" >
<input name="placeorder" type="image" src="http://switchon.org.in/India/wp-content/uploads/2008/11/090023.jpg" alt="Click to place order" value="Place Order" onclick="placeorder();this.src='http://www.jtduoff.fr/IMG/cache-443x640/OFF_2009_logo_cprs-443x640.jpg';this.disabled=true;document.forms['form_name'].submit();" />
</form>
</body>
</html>

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
bede123Author Commented:
thank you. the last option will work for me, thanks.

i just need to learn how to properly put the validation items in the head section.

thanks

zac
0
leakim971PluritechnicianCommented:
You're welcome! Thanks for the points! Maybe this link can help you : http://www.javascript-coder.com/html-form/javascript-form-validation.phtml
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
Web Languages and Standards

From novice to tech pro — start learning today.