Web Analytics Made Easy -
StatCounter loop - CodingForum

Announcement

Collapse
No announcement yet.

loop

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • loop

    hello, my question is

    how can I get this animation to loop, a couple of times ???

    <script>
    var y=0;

    function animateIt(){
    var theDivision=document.getElementById('animatedDiv');
    var yMax=2000;
    if(y<=yMax){
    theDivision.style.top=y;
    y=y+60;
    setTimeout("animateIt()",10);
    document.forms.theform.thetextbox.value="thank you.";
    }
    }
    </script>

    thanks and thanks to ASAAKI
    <marquee>thanks</marquee>

  • #2
    This really isn't DOM Scripting in the sense appropriate for this forum - moving to the Javascript Programming forum.
    jasonkarldavis.com

    Comment


    • #3
      <script>
      var y;

      function animateIt(){
      var theDivision=document.getElementById('animatedDiv');
      var yMax=2000;
      if(y<=yMax){
      theDivision.style.top=y;
      y=y+60;
      setTimeout("animateIt()",10);
      document.forms.theform.thetextbox.value="thank you.";
      }

      for ( var i = 0; i < 5; i++) {
      y = 0;
      animateIt();
      }
      }
      </script>

      that should do what you want.
      bluemood | devedge | devmo | MS Dev Library | WebMonkey | the Guide

      i am a loser geek, crazy with an evil streak,
      yes i do believe there is a violent thing inside of me.

      Comment


      • #4
        error ???

        when I run the code above.. it comes up with

        out of memory line 15

        I am not to sure why.. can you help

        Last edited by chris_angell; Jul 15, 2002, 01:05 PM.
        <marquee>thanks</marquee>

        Comment


        • #5
          k, noticed a couple of mistakes that missed before. try this:

          <script>
          var y;

          function animateIt(){
          var theDivision=document.getElementById('animatedDiv');
          var yMax=2000;
          if (y <= yMax) {
          theDivision.style.top = y +'px';
          y += 60;
          setTimeout("animateIt()",10);
          }
          }

          for ( var i = 0; i < 5; i++) {
          y = 0;
          document.forms.theform.thetextbox.value = "thank you.";
          animateIt();
          }
          }
          </script>
          bluemood | devedge | devmo | MS Dev Library | WebMonkey | the Guide

          i am a loser geek, crazy with an evil streak,
          yes i do believe there is a violent thing inside of me.

          Comment


          • #6
            ?? is it me

            this is the code. am I just doing something stupid wrong

            <script>
            var y;

            function animateIt(){
            var theDivision=document.getElementById('animatedDiv');
            var yMax=2000;
            if (y <= yMax) {
            theDivision.style.top = y +'px';
            y += 60;
            setTimeout("animateIt()",10);
            }
            }

            for ( var i = 0; i < 5; i++) {
            y = 0;
            animateIt();
            }
            }
            </script>
            </head>

            <body>
            <form name="theform">
            <input type="text" name="thetextbox" size="20">
            <input type="button" value="Move!" onClick="animateIt()">
            </form>

            <div id="animatedDiv"><img src="images/_black_arrow.gif" width="85" height="85"></div>

            </body>


            ????? thanks to john
            <marquee>thanks</marquee>

            Comment


            • #7
              are you still having the same problem, or what?
              bluemood | devedge | devmo | MS Dev Library | WebMonkey | the Guide

              i am a loser geek, crazy with an evil streak,
              yes i do believe there is a violent thing inside of me.

              Comment


              • #8
                it is coming up with errors that I do not understand ????

                when I run the script, there are eorros, I have tried correct this.. is there anything obvious you can see going wrong.. regarding the script above..

                cheers
                Last edited by chris_angell; Jul 16, 2002, 05:34 AM.
                <marquee>thanks</marquee>

                Comment


                • #9
                  Re: ?? is it me

                  How about something like this...

                  var numberofLoops=2000;
                  var howfardown=200;
                  function animateIt(y){
                  var theDivision=document.getElementById('animatedDiv');
                  y=Number(y)%howfardown;
                  theDivision.style.top = y +'px';
                  }

                  for ( var i = 0; i < numberofLoops; i++) {
                  setTimeout("animateIt("+i+")",10);
                  }

                  Comment

                  Working...
                  X