I want to modify this code so that the value is a variable and so that the progress bar refreshes in real time (or the smallest meter of time possible – milliseconds)
I am going to “seed” the current time to drive the updates
<script type="text/javascript">
$(function()
{
$("#container").progressbar({ value: 0 });
});
</script>
Fosco’s edit: (currently not working)
<script type="text/javascript">
updateProgress(0);
function updateProgress(newvalue)
{
$("#container").progressbar({ 'value': newvalue });
newvalue = newvalue + 1
if (newvalue < 101) setTimeout('updateProgress(' + newvalue + ');',100);
}
</script>
The first bit is easy
The next bit not so easy. The purpose of a progress bar is to show progress, so what is it showing the progress of? You should call this function from code that is performing whatever action it is reflecting, as often as you can.
If you just want to loop the code, then set a timeout to call the function after 1 ms, and repeat.
Worth mentioning that the actual smallest time resolution of most browsers is not 1 ms, but quite a bit less.