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 2 of 2
  1. #1
    New to the CF scene
    Join Date
    Mar 2009
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    adding line to script

    Hi,

    I have this script for a countdown clock and like to add a line. I like to have a line that says merry christmas on christmas day. Can anyone help me?

    Astrid

    <script language="javascript">
    today = new Date();
    BigDay = new Date("December 25, 2009")
    msPerDay = 24 * 60 * 60 * 1000 ;
    timeLeft = (BigDay.getTime() - today.getTime());
    e_daysLeft = timeLeft / msPerDay;
    daysLeft = Math.floor(e_daysLeft);
    e_hrsLeft = (e_daysLeft - daysLeft)*24;
    hrsLeft = Math.floor(e_hrsLeft);
    minsLeft = Math.floor((e_hrsLeft - hrsLeft)*60);
    document.write( " "+daysLeft+" days until Christmas!");
    </script>

  • #2
    Supreme Master coder! Philip M's Avatar
    Join Date
    Jun 2002
    Location
    London, England
    Posts
    17,733
    Thanks
    202
    Thanked 2,508 Times in 2,486 Posts
    Here you are:-

    Code:
    <script type = "text/javascript">
    today = new Date();
    BigDay = new Date("December 25, 2009")
    msPerDay = 24 * 60 * 60 * 1000 ;
    timeLeft = (BigDay.getTime() - today.getTime());
    e_daysLeft = timeLeft / msPerDay;
    daysLeft = Math.floor(e_daysLeft);
    e_hrsLeft = (e_daysLeft - daysLeft)*24;
    hrsLeft = Math.floor(e_hrsLeft);
    minsLeft = Math.floor((e_hrsLeft - hrsLeft)*60);
    if (daysLeft > 0) {
    document.write(daysLeft + " days until Christmas!");
    }
    if (daysLeft == 0) {
    document.write ("Merry Christmas!");  // or "Season\'s Greetings" in these politically correct times.
    }
    // after 25th December nothing will be displayed.
    
    </script>
    Note that <script language="javascript"> is deprecated and obsolete. Use <script type = "text/javascript"> instead.



    Quizmaster: If something in dispute is divided equally, it is referred to as splitting the ... what?
    Contestant: Atom.
    Last edited by Philip M; 03-05-2009 at 12:01 PM. Reason: Add code tags


  •  

    Posting Permissions

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