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
    May 2007
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Question Countdown date function problems

    Hi! I am working on a hw assignment which gave step-by-step instructions, but my page is still not displaying right (the instructions were pretty vague, but I followed them as the chapter described). I have only had one chapter of JavaScript (in this class which is HTML) so I'm not very familiar with it. I've gone over the code a bunch of times, but still cannot find where I went wrong. Nothing shows up on the web page at all, and I'm not sure why. Any help would be greatly appreciated. Here's the code for the .js file:

    Code:
    function XmasDays(thisDate) {
       var XMYear=thisDate.getFullYear();
       var XMDay=new Date("December, 25, 2005");
       XMDay.setFullYear(XMYear);
       var dayTotal=(XMDay-thisDate)/(1000*60*60*24);
       dayTotal=Math.round(dayTotal);
       return dayTotal;
    } 
    
    function showDate(thisDate) {
       var thisWDay=thisDate.getDay();
       var thisDay=thisDate.getDate();
       var thisMonth=thisDate.getMonth();
       var thisYear=thisDate.getFullYear();
       var monthName=new Array("January", "February", "March", "April", "May", "June", "July", "August",
          "September", "October", "November", "December");
       var wdayName=new Array("Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday");
       var dateString=+wdayName[thisWDay]+", "+monthName[thisMonth]+", "+thisDay+", "+thisYear;
       return dateString;
    }
    This is the embedded script:

    Code:
    <script type="text/javascript">
       var today=new thisDate("December, 24, 2007");
       var niceDate=dateString(today);
       var daysLeft=dayTotal(today);
       document.write(niceDate+"<br />");
    if(daysLeft>1) {
       document.write("Only "+daysLeft+" days until Christmas");
    }  else {
          if(daysLeft==1) {
             document.write("Last day for Christmas shopping");
       } else {
             document.write("Happy Holidays from North Pole Novelties");
       }
    }
    </script>

  • #2
    New to the CF scene
    Join Date
    May 2007
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Never mind...I got it!


  •  

    Posting Permissions

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