Re: Need help with simple progress bar



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/
.



Relevant Pages

  • Re: Cancel Print
    ... you can prevent the user from printing the page in script. ... Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/ ...
    (microsoft.public.scripting.jscript)
  • Re: image dragging outside of window, scroll bars
    ... I'm working on a script that involves dragging an element around a ... Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/ ...
    (comp.lang.javascript)
  • Re: atomic cross-window IPC?
    ... trigger(); ... Adding a script call at the end of the body won't ensure it is loaded. ... Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/. ...
    (comp.lang.javascript)
  • Re: Writing text to

    ... is there a more universal method? ... Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/ ...
    (comp.lang.javascript)
  • Re: how can i retrieve the name of form when one of the element name in this form is name
    ... but i can not able to retrieve the name of the form, ... Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/ ...
    (comp.lang.javascript)