View Full Version : loop
chris_angell
07-12-2002, 10:45 AM
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 :eek:
This really isn't DOM Scripting in the sense appropriate for this forum - moving to the Javascript Programming forum.
joh6nn
07-12-2002, 05:34 PM
<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.
chris_angell
07-15-2002, 06:01 PM
when I run the code above.. it comes up with
out of memory line 15
I am not to sure why.. can you help
:)
joh6nn
07-15-2002, 06:53 PM
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>
chris_angell
07-15-2002, 07:04 PM
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>
????? :rolleyes: thanks to john
joh6nn
07-15-2002, 07:43 PM
are you still having the same problem, or what?
chris_angell
07-16-2002, 10:32 AM
:( 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
tamienne
07-16-2002, 04:12 PM
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);
}
vBulletin® v3.8.2, Copyright ©2000-2012, Jelsoft Enterprises Ltd.