Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New to the CF scene
    Join Date
    Dec 2003
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    countdown - countup script???

    Hi,

    I really have a big problem and hope anyone here can help me. I would like to put the 'countup' AND the 'countdown' scprit on my homepage, but they don't work together.
    I read the instruction how to change the code to make them work together, but for some reason they still don't. I don't know why, maybe I'm doing something wrong.

    Could someone please please help me and write me how to change it, or even change it for me and just paste me the two changed scripts?

    I would really appreciate it so much, because I had such a hard time changing everything and it still didn't work.

    Please, please help me!

    Thanks in advance!

  • #2
    Regular Coder
    Join Date
    Jun 2002
    Posts
    338
    Thanks
    0
    Thanked 0 Times in 0 Posts
    You really only need one function:

    Code:
    function countIt(dateStr, evtStr) {
    
    	var now = new Date(), then = new Date(dateStr);
    	var diff = Math.floor((now.getTime() - then.getTime()) / (1000*60*60*24));
    
    	return Math.abs(diff) + ' days ' + ((diff < 0) ? ' \'till ' : ' since ') + evtStr + '.<br />';
    
    }
    Then, to write it to the page, you could do something like this:

    Code:
    document.write(countIt('December 25, 2003', 'Christmas 2003'));
    document.write(countIt('January 1, 2004', 'New Year 2004'));
    Hope that helps!

    Happy coding!

  • #3
    New to the CF scene
    Join Date
    Dec 2003
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Thank you soooooooooo much, I'll try!


  •  

    Posting Permissions

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