Go Back   CodingForums.com > :: Client side development > JavaScript programming

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 08-04-2002, 07:20 PM   PM User | #1
snakedevil1
New Coder

 
Join Date: Jun 2002
Posts: 78
Thanks: 0
Thanked 0 Times in 0 Posts
snakedevil1 is an unknown quantity at this point
help with animation function

Everytime i run this code through, i get a line 66 character 1 object expected error. i have NO idea what it is. Please help!

var currentstate=1;

function GoTo(id)
{
var howfar;
var way;
if (id > currentstate)
{ howfar=id-currentstate; way="right"; } else { howfar=currenstate-id; way="left"; }
var distance;
var result;
switch (way) {
case "right"
distance=howfar*75;
result=document.getElementById(selector).style.left+distance;
break;
case "left"
distance=howfar*75;
result=document.getElementById(selector).style.left-distance;
break;
}

if(document.getElementById(selector).style.left=result)
{clearTimeout(animation);animation=0;} else {
function="GoTo(" + id + ");";
animation=setTimeout(function,50);}
}
__________________
Computers are simple for the complex mind, yet complex for the simple mind
snakedevil1 is offline   Reply With Quote
Old 08-04-2002, 08:52 PM   PM User | #2
snakedevil1
New Coder

 
Join Date: Jun 2002
Posts: 78
Thanks: 0
Thanked 0 Times in 0 Posts
snakedevil1 is an unknown quantity at this point
fixed it up a little, but still get the same error:
var currentstate=1;

function GoTo(id)
{
var howfar;
var way;
if (id > currentstate)
{ howfar=id-currentstate; way="right"; } else { howfar=currenstate-id; way="left"; }
var distance;
var result;
switch (way) {
case "right"
distance=howfar*75;
result=document.getElementById(selector).style.left+distance;
break;
case "left"
distance=howfar*75;
result=document.getElementById(selector).style.left-distance;
break;
}

if(document.getElementById(selector).style.left=result)
{clearTimeout(animation);animation=0;} else {
animation=setTimeout(GoTo,50,id);}
}
__________________
Computers are simple for the complex mind, yet complex for the simple mind
snakedevil1 is offline   Reply With Quote
Old 08-04-2002, 09:16 PM   PM User | #3
snakedevil1
New Coder

 
Join Date: Jun 2002
Posts: 78
Thanks: 0
Thanked 0 Times in 0 Posts
snakedevil1 is an unknown quantity at this point
thanx for the help, but i get the same error, this time when i click on it.
by the way, my website is at vip3r.port5.com
__________________
Computers are simple for the complex mind, yet complex for the simple mind
snakedevil1 is offline   Reply With Quote
Old 08-04-2002, 09:18 PM   PM User | #4
Graeme Hackston
Regular Coder

 
Join Date: Jun 2002
Posts: 624
Thanks: 0
Thanked 0 Times in 0 Posts
Graeme Hackston is an unknown quantity at this point
I deleted my reply hoping not to confuse you. I was wrong, all the brackets are there.
Graeme Hackston is offline   Reply With Quote
Old 08-04-2002, 09:30 PM   PM User | #5
snakedevil1
New Coder

 
Join Date: Jun 2002
Posts: 78
Thanks: 0
Thanked 0 Times in 0 Posts
snakedevil1 is an unknown quantity at this point
thanx for ur help. now, after a little bit of editing, i get a line 36 character 1 error. any help would be appreciated!

var currentstate=1;

function GoTo(id) {
var howfar;
var way;
if (id > currentstate) {
howfar=id-currentstate; way="right";
} else {
howfar=currenstate-id; way="left";
}
var distance;
var result;
switch (way) {
case "right":
distance=howfar*75;
result=document.getElementById(selector).style.left+distance;
break;
case "left":
distance=howfar*75;
result=document.getElementById(selector).style.left-distance;
break;
}
if(document.getElementById(selector).style.left=result) {
clearTimeout(animation);animation=0;
} else {
animation=setTimeout(GoTo,50,id);}
}
__________________
Computers are simple for the complex mind, yet complex for the simple mind
snakedevil1 is offline   Reply With Quote
Old 08-04-2002, 09:37 PM   PM User | #6
Graeme Hackston
Regular Coder

 
Join Date: Jun 2002
Posts: 624
Thanks: 0
Thanked 0 Times in 0 Posts
Graeme Hackston is an unknown quantity at this point
what is "selector"? If it's an element id it should be like this:

('selector')
Graeme Hackston is offline   Reply With Quote
Old 08-04-2002, 09:58 PM   PM User | #7
snakedevil1
New Coder

 
Join Date: Jun 2002
Posts: 78
Thanks: 0
Thanked 0 Times in 0 Posts
snakedevil1 is an unknown quantity at this point
ok,thanx.
now that i fixed it, i got a line 43 character 1 error.
var currentstate=1;

function GoTo(id) {
var howfar;
var way;
if (id > currentstate) {
howfar=id-currentstate; way="right";
} else {
howfar=currenstate-id; way="left";
}
var distance;
var result;
switch (way) {
case "right":
distance=howfar*75;
result=document.getElementById('selector').style.left+distance;
break;
case "left":
distance=howfar*75;
result=document.getElementById('selector').style.left-distance;
break;
}
if(document.getElementById('selector').style.left=result) {
clearTimeout(animation);animation=0;
} else {
animation=setTimeout(GoTo,50,id);}
}
__________________
Computers are simple for the complex mind, yet complex for the simple mind
snakedevil1 is offline   Reply With Quote
Old 08-04-2002, 10:06 PM   PM User | #8
Graeme Hackston
Regular Coder

 
Join Date: Jun 2002
Posts: 624
Thanks: 0
Thanked 0 Times in 0 Posts
Graeme Hackston is an unknown quantity at this point
Just guessing but try this

animation=setTimeout(GoTo(),50);
}
Graeme Hackston is offline   Reply With Quote
Old 08-04-2002, 10:09 PM   PM User | #9
Graeme Hackston
Regular Coder

 
Join Date: Jun 2002
Posts: 624
Thanks: 0
Thanked 0 Times in 0 Posts
Graeme Hackston is an unknown quantity at this point
Actually I think it should be like this

animation=setTimeout('GoTo()',50);
}
Graeme Hackston is offline   Reply With Quote
Old 08-04-2002, 10:17 PM   PM User | #10
snakedevil1
New Coder

 
Join Date: Jun 2002
Posts: 78
Thanks: 0
Thanked 0 Times in 0 Posts
snakedevil1 is an unknown quantity at this point
i need to pass id to GoTo though, otherwise it wouldn't know where to go, right? thanx for ur help!
__________________
Computers are simple for the complex mind, yet complex for the simple mind
snakedevil1 is offline   Reply With Quote
Old 08-04-2002, 10:22 PM   PM User | #11
Graeme Hackston
Regular Coder

 
Join Date: Jun 2002
Posts: 624
Thanks: 0
Thanked 0 Times in 0 Posts
Graeme Hackston is an unknown quantity at this point
Maybe this?

animation=setTimeout('GoTo(id)',50);
}
Graeme Hackston is offline   Reply With Quote
Old 08-04-2002, 10:28 PM   PM User | #12
snakedevil1
New Coder

 
Join Date: Jun 2002
Posts: 78
Thanks: 0
Thanked 0 Times in 0 Posts
snakedevil1 is an unknown quantity at this point
i think what u mean is this:
setTimout("'GoTo(' + id + ');'");
and nope, still doesn't work
__________________
Computers are simple for the complex mind, yet complex for the simple mind
snakedevil1 is offline   Reply With Quote
Old 08-04-2002, 10:39 PM   PM User | #13
snakedevil1
New Coder

 
Join Date: Jun 2002
Posts: 78
Thanks: 0
Thanked 0 Times in 0 Posts
snakedevil1 is an unknown quantity at this point
ok, i rewrote it so it makes some more sense now. Now it looks like this:

var wheretogo;
var whereis;
function GoTo(id)
{
whereis=document.all.selector.offsetLeft;
var whereisbyid;
switch(whereis)
{

case: 75
whereisbyid=1;

case: 150
whereisbyid=2;

case: 225
whereisbyid=3;

case: 300
whereisbyid=4;
}

if(whereisbyid>id)
{way="left"}

wheretogo=id*75;
var animation=setInterval("GoToPlace();",50);
}

function GoToPlace()
{

if(wheretogo != whereis)
{ whereis=whereis+1; } else {clearInterval(animation)}

}
__________________
Computers are simple for the complex mind, yet complex for the simple mind
snakedevil1 is offline   Reply With Quote
Old 08-04-2002, 10:41 PM   PM User | #14
snakedevil1
New Coder

 
Join Date: Jun 2002
Posts: 78
Thanks: 0
Thanked 0 Times in 0 Posts
snakedevil1 is an unknown quantity at this point
i still get a line 30 character 8 object expected error
__________________
Computers are simple for the complex mind, yet complex for the simple mind
snakedevil1 is offline   Reply With Quote
Old 08-04-2002, 10:41 PM   PM User | #15
Graeme Hackston
Regular Coder

 
Join Date: Jun 2002
Posts: 624
Thanks: 0
Thanked 0 Times in 0 Posts
Graeme Hackston is an unknown quantity at this point
Still just guessing.

Where does "animation" come in? Is it part of another script?
Graeme Hackston is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 06:19 PM.


Advertisement
Log in to turn off these ads.