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);} Hi having a lot of trouble adding a replace child to the .appendChild .createTextNode after the middle of the above function Right now its stacking new text links instead of replacing the old one with the new one. Getting tired of reading up on it with no luck. Please let me know, thank you very much.
function changelink() { document.getElementById("url").href = arr[new Date().getSeconds()*2-1][0]; document.getElementById("url").innerHTML = arr[new Date().getSeconds()*2-2][0]; setTimeout('changelink();',1000); } PHP: Try like that
Morishani, thank you soooo much that was really gettin to me. That helped a lot, now the array won't start over when it gets to the end. Anyone know why? I added this to the end of the function with no luck. I need a better one. if (arr.length < 61) return arr;}
I have an array that has 60 items, with that function right under it. It supposed to change every second which it does now but when it gets to the end of the array the 60th item it stops. Doesn't start over.
function changelink() { document.getElementById("url").href = arr[(new Date().getSeconds()*2-1)%60][0]; document.getElementById("url").innerHTML = arr[(new Date().getSeconds()*2-2)%60][0]; setTimeout('changelink();',1000); } PHP: Try like that
Doesn't work but someone gave me something else by rewriting the whole thing, so if you can't come up with anything thats ok. If you ever think of another way to have the seconds reloop when they get to the end please let me know.
Mmmm , lets try again var i = 0; function changelink() { document.getElementById("url").href = arr[i*2-1][0]; document.getElementById("url").innerHTML = arr[i*2-2][0]; setTimeout('changelink();',1000); i++; if (i>60) i=0; } PHP: Try like that
No worky, but thats ok, Morishani, you've already helped a lot. Someone already gave me one for a generic time, was looking for something to change right on the second, then to start over. If anyone knows how to alter mine to do that please let me know.