View Full Version : Waitbar in javascript for HTML

06-10-2008, 01:03 PM

I wrote a little form with a submit button. When the user clicks on submit, a javascript function is executed. That function makes some expensive queries and needs 5-10 seconds before it finishes. Therefore I would like to show an animated gif mimiking a waitbar while the function is calculating. My problem is that when I do that, he first executes the function (5-10 secs), then shows the waitbar, then shows the results... Is there a way to force the display of the waitbar before he begins (and during) the execution?

Thank you for your help!


Philip M
06-10-2008, 05:25 PM
If you use a wait while loading (or whatever) script like this:-

font: bold 24px MS Sans Serif;
padding: 6px;

<span id = "a" class = "styling"></span>

<script type = "text/javascript">
var num = 0;
var tim;
var txt = "Loading, please wait ........";
document.getElementById("a").innerHTML = txt;
function showLoad() {
num ++;
if (num == 5) { // erase after 5 seconds, adjust to suit
else {
tim = window.setTimeout("showLoad()", 1000);



onsubmit = "showload(); yourOtherFunction();"

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum