SitePoint Sponsor

User Tag List

Results 1 to 5 of 5
  1. #1
    SitePoint Addict
    Join Date
    May 2006
    Posts
    349
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Need help replacing an .appendChild please.

    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.

  2. #2
    SitePoint Wizard
    Join Date
    Nov 2004
    Location
    Nelson BC
    Posts
    2,310
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    What if you use innerHTML?

    document.getElementById("url").innerHTML = arr[new Date().getSeconds()*2-2][0];

  3. #3
    SitePoint Addict
    Join Date
    May 2006
    Posts
    349
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Yes that works, tried it already. But it still won't loop and start over when it gets to the end, any idea why?

  4. #4
    SitePoint Addict
    Join Date
    May 2006
    Posts
    349
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    adding this to the end of the function does't seem to help. I need a better if command.

    if (arr.length < 61)
    return arr;}

  5. #5
    SitePoint Addict
    Join Date
    May 2006
    Posts
    349
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Someone gave me something else by rewriting it. But I'd still like the seconds someday. If you ever think of another way to have the seconds reloop when they get to the end please let me know.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •