[thelist] setTimeout Question

Michael Robertson mike at mikeemedia.com
Mon Jul 15 22:10:01 CDT 2002


I have a script that writes out images in a graph style like below. It works
great like this. What I want to do is make them write out sequencially sort
of like an animated thing. My idea was to call the functions in a
setTimeout() like this:

setTimeout("writeRight()",1000)

but it doesn't work. Why not? And is there a better way to accomplish this?
Thanks.

<script language="JavaScript" type="text/JavaScript">
 var intSteps=0;
 var intTop=200;
 var intLeft=200;
 var intTotal=5400;
 var strChar="char2";
 var rndTotal=(intTotal/500) *500

 function writeRight(){
  document.write('<img style="vertical-align:bottom;float:right"
src="../images/footStepsRight.gif">');
 }

 function writeLeft(){
  document.write('<img style="vertical-align:top;float:left"
src="../images/footStepsLeft.gif">');
 }

 while(intSteps<rndTotal){
  document.write('<span style="position:absolute;top:' + intTop + 'px;left:'
+ intLeft + ' px;height:45px;width:36px;padding:0px">');
  writeLeft()
  intSteps+=500;intLeft+=27
   if (intSteps < rndTotal) {
    writeRight()
   }
  document.write('</span>')
  }
  document.write('<img src="../images/' + strChar + 'D.gif"
style="position:absolute;top:' + (intTop + 2) + 'px;left:' + (intLeft + 10)
+ 'px">')
  document.write('<span style="position:absolute;top:' + (intTop + 10) +
'px;left:' + (intLeft + 36) +
'px;padding:1px;color:#175692;font-weight:bold;background-color:#fe7a22">')
  document.write(intTotal + "/" + rndTotal)
  document.write('</span>')
</script>





More information about the thelist mailing list