Re: Need help with simple progress bar
- From: Randy Webb <HikksNotAtHome@xxxxxxx>
- Date: Fri, 30 Jun 2006 11:46:51 -0400
john@xxxxxxxxxxxxxxxxxxxxx said the following on 6/30/2006 10:36 AM:
Why is my progress bar displayed only after it's reached 100%?
Because it happens in about 2 ms of time. It gets updated, you just don't see it being updated.
<script type="text/javascript">
var counter = 0;
function setPercent(num){
counter++;
if (counter>10)
{
document.getElementById("bar").style.width = counter + "px";
}
document.getElementById("bar").innerHTML= counter + "%";
if (counter == 100)
{
window.clearInterval(myInterval)
}
}
var myInterval = window.setInterval('setPercent()',60);
</script>
<div id="bar"></div>
And no, adding a counting loop is not the way to delay JS script.
--
Randy
comp.lang.javascript FAQ - http://jibbering.com/faq & newsgroup weekly
Temporarily at: http://members.aol.com/_ht_a/hikksnotathome/cljfaq/
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
.
- References:
- Need help with simple progress bar
- From: john
- Need help with simple progress bar
- Prev by Date: Re: Need help with simple progress bar
- Next by Date: shortcut for document.getElementById and some error
- Previous by thread: Re: Need help with simple progress bar
- Next by thread: shortcut for document.getElementById and some error
- Index(es):