ruperik
07-15-2009, 08:21 PM
so i want a loading img to display when a javascript function is called and be hidden when the function finishes. the function takes a bit of time (anywhere from 1 sec to 10 secs usually), so i don't want the user to think nothing is happening. below is the relevant code. the first snippet sets up the loading img and a label for it. the second and third snippets are at the beginning and end of the function (respectively) and turn visibility on and off (respectively). for some reason, it can't ever see it turn on. a reasonable enough amount of time is elapsing such that i expect to see it. any ideas?
<div class="data">
<img id="loading" src="pics/loading.gif" style="visibility: hidden" />
<label id="loading_lbl" style="visibility: hidden"> Loading...<label>
</div>
document.getElementById("loading").style.visibility = "visible";
document.getElementById("loading_lbl").style.visibility = "visible";
document.getElementById("loading").style.visibility = "hidden";
document.getElementById("loading_lbl").style.visibility = "hidden";
<div class="data">
<img id="loading" src="pics/loading.gif" style="visibility: hidden" />
<label id="loading_lbl" style="visibility: hidden"> Loading...<label>
</div>
document.getElementById("loading").style.visibility = "visible";
document.getElementById("loading_lbl").style.visibility = "visible";
document.getElementById("loading").style.visibility = "hidden";
document.getElementById("loading_lbl").style.visibility = "hidden";