pause to show processing image

I would like to show a 'processing form' image when user clicks submit on a simple html form.
Because my form is very simple the images doesnt even have time to load before the form has been submitted.

How can I delay the submit of the form for 2 seconds?

Below is my javascript to display image on submit.

Ideas would be very helpful!

Many Thanks
<script type="text/javascript">

function loadSubmit() {

ProgressImage = document.getElementById('progress_image');
document.getElementById("progress").style.visibility = "visible";
setTimeout("ProgressImage.src = ProgressImage.src",3000);
//NEED TO WAIT HERE FOR 2 SECONDS!
return true;
}

</script>

Open in new window

Steve TinsleyAsked:
Who is Participating?
 
leakim971Connect With a Mentor PluritechnicianCommented:
Hello sjtinsley83,

Try : setTimeout("document.myForm.submit();", 3000);


<!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" />
<title>Wait</title>
<script type="text/javascript">
	function loadSubmit() {
	        ProgressImage = document.getElementById('progress_image');
		document.getElementById("progress").style.visibility = "visible";
		setTimeout("document.myForm.submit();", 3000);	
	}
</script>
</head>
<body>
<form name="myForm" id="myForm" action="http://www.experts-exchange.com">
	<INPUT type=button value="Go to EE" onClick="loadSubmit();">
</form>
<img name="ProgressImage" id="progress" style="visibility:hidden;" src="http://www.bitemehere.com/VisualQuote/Images/PleaseWait.gif" alt="ProgressImage">
</body>
</html>

Open in new window

0
 
Michel PlungjanIT ExpertCommented:
Alternatively use ajax
0
 
leakim971PluritechnicianCommented:
Thanks for the points! Happy new year!
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.