Page 1 of 1

Can someone please tell me what wrong with my link function?

Posted: Thu Oct 26, 2006 7:52 am
by Nicole
function changelink(){
document.getElementById("url").href = arr[new Date().getSeconds()*2-1][0];
document.getElementById("url").appendChild(document.createTextNode(arr[new Date().getSeconds()*2-2][0]));
setTimeout('changelink()',1000);}

Hello, things are sort of working. this function is causing text links I have in an array to stack up, instead of replacing the one from before. Anyone know why? So I am getting a page full of web page links with a new one every second. :lol:

I also can't get it to loop when it gets to the end of the last seconds. These change every second and I have 60 of them in the array, when it gets to the last one it stops. The problem is in the function somewhere everything else is fine. Someone please help me, thank you very much.

Posted: Thu Oct 26, 2006 8:09 am
by feyd
Don't you need a removeChild call to go along with your appendChild call?

Posted: Thu Oct 26, 2006 8:41 am
by Nicole
Thanks, any idea how?

Posted: Thu Oct 26, 2006 1:15 pm
by feyd
That would depend on what you need the removal to do. If you want to remove the first child parent.firstChild is the property to give removeChild(); if it's the preceding child, then I believe it's parent.lastChild.

Posted: Fri Oct 27, 2006 1:03 am
by Nicole
What do you mean by removal? So that it replaces the link from before and doesn't stack up?