Hardi
asked on
force refresh/repaint screen while processing?
I have something like:
for(i=0; i<10; i++)
{
document.all.textboxProces s.value = i;
process(i);
}
But the value of textboxProcess is not updated until the loop finish.
How can I force screen refresh/repaint inside the loop?
for(i=0; i<10; i++)
{
document.all.textboxProces
process(i);
}
But the value of textboxProcess is not updated until the loop finish.
How can I force screen refresh/repaint inside the loop?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Don't use document.all. You scripts will run much more efficiently without it, and your scripts will also run cross-browser.
Use document.forms[0].textboxP orcess.val ue or document.getElementById("t extboxProc ess").valu e instead:
<html>
<head>
<script language="javascript">
var upperLimit = 10, msec = 200;
function advanceTick()
{
var newTick = document.getElementById("t extboxProc ess").valu e;
if(newTick < upperLimit)
{
document.forms[0].textboxP rocess.val ue = ++newTick;
timer = setTimeout("advanceTick()" , msec);
}
}
window.onload = advanceTick;
</script>
</head>
<body>
<form>
Test value here: <input type="text" id="textboxProcess" name="textboxProcess" size="8" maxlength="8" value="-1">
</form>
</body>
</html>
Also the toString() call isn't necessary, and you can just get the value from the text input.
This also has the advantage that it will work in all JS-capable browsers.
Use document.forms[0].textboxP
<html>
<head>
<script language="javascript">
var upperLimit = 10, msec = 200;
function advanceTick()
{
var newTick = document.getElementById("t
if(newTick < upperLimit)
{
document.forms[0].textboxP
timer = setTimeout("advanceTick()"
}
}
window.onload = advanceTick;
</script>
</head>
<body>
<form>
Test value here: <input type="text" id="textboxProcess" name="textboxProcess" size="8" maxlength="8" value="-1">
</form>
</body>
</html>
Also the toString() call isn't necessary, and you can just get the value from the text input.
This also has the advantage that it will work in all JS-capable browsers.
> window.repaint;
Clientside JS doesn't give you that sort of fine-grained control over graphics/screen.
Remember, a Web browser is essentially just a glorified document viewer. ;^)
Clientside JS doesn't give you that sort of fine-grained control over graphics/screen.
Remember, a Web browser is essentially just a glorified document viewer. ;^)
ASKER
thanks splamunge and Zontar
my code is now messed up coz it's not that simple =P
but i know how to use setTimeout
and i'll start using getelementbyid =)
my code is now messed up coz it's not that simple =P
but i know how to use setTimeout
and i'll start using getelementbyid =)
ASKER
so there is no way you can do such as
window.repaint;
or anything?
i'll try that advanceTick...