On pages that take more than a few seconds to complete, its a good idea to show some type of in-progress meter. Things like bulk email processing and large file uploads are good candidates. Often this doesn’t need to be as complicated as a real progress meter, where you show the actual percentage complete. Instead, an “in progress” meter just gives feedback to the user to let them know that something is going on.
I usually place a hidden element on the page, then use JavaScript to make it appear when the form is submitted. Something like:
<p style="visibility:hidden" id="inprogress">
<img id="inprogress_img" src="progress.gif">
Please Wait...
</p>
<input type="submit" onclick="document.getElementById('inprogress').style.visibility='visible'">
Note that there is an image used in the in-progress message, this is important. A static “Please Wait” message tells your user they should wait, but without the feedback of the moving image, they could still get the impression something is locked up. You can get some awesome free progress meters from http://www.ajaxload.info.
Of course Internet Explorer throws a wrench into things. IE will stop any animated gifs from animating when the form is submitted. This is a problem in IE6 and 7. This is far worse than having no progress meter, since it appears as if something has locked up. But there is a work around. We just need to kick start the animation after the form submits. We do this by resetting the source of the image with JavaScript. We have to reset the src after the form submits, and the form submits when our function returns. So we make use of the setTimeout function, which executes a line of JavaScript after a specified number of milliseconds. We’ll also throw in an anti-double submit feature similar to what I mentioned in my last post.
<script language="JavaScript">
var submitted = false;
function doSubmit() {
if (! submitted) {
submitted = true;
ProgressImg = document.getElementById('inprogress_img');
document.getElementById("inprogress").style.visibility = "visible";
setTimeout("ProgressImg.src = ProgressImg.src",100);
return true;
}
else {
return false;
}
}
</script>
<input type="submit" onclick="return doSubmit()">
If your form is long enough that it needs scroll bars, be sure to place the in-progress message where the user will see it when they click the submit button.

Ikesacolick says:
Good solution. Thank You.
One small issue. To get this to work, you need to set the id=’inprogress_img’ in the img tag as in:
img id=”inprogress_img” src=”progress.gif”
7 March 2007, 2:52 pmRyan Stille says:
Good call, I missed that in my example. Its been updated now.
7 March 2007, 3:03 pmgesmith says:
Thanks for this very good solution. No thanks to IE and all of it’s headaches. :X
26 March 2007, 8:14 amAndrew Violette says:
Perfect. Worked like a charm!
10 April 2007, 1:59 pmStephen Scotti says:
I’m wanting to do something like this also, but instead of submitting a form I’m using a
28 July 2007, 8:50 pmaearly says:
Nice solution! Glad you found a way around this problem.
10 December 2007, 5:16 pmAndrisi says:
Nice, but how (where) do I hide the progress image?
6 January 2008, 4:41 amMJJ says:
Hi can i know how to hide the progress image when the processing is over? Thanks!
14 March 2008, 4:02 amMuthu says:
Thanks ! Can you let me know, if there is a way to keep the position of the image dyanmic? next to cursor/ mouse pointer ?
27 June 2008, 11:08 amGary says:
With the ajaxload noted above this was the perfect solution for what I was trying to do. Thanks much!
27 January 2009, 2:45 amTolenca says:
Thanks…thanks…thanks a lot
12 September 2009, 11:08 pmMike says:
Hi,
Love this post! Trying to implement, but don't see…
1) Where you submit the form, and
2) Where you check if submit successful, and
3) Then reset to "hidden".
Can you help me with this.
I'm a rookie, so go easy on me…
Thanks Mike
20 September 2009, 4:38 pm