View Full Version : Countdown date function problems

05-03-2007, 04:38 AM
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:

function XmasDays(thisDate) {
var XMYear=thisDate.getFullYear();
var XMDay=new Date("December, 25, 2005");
var dayTotal=(XMDay-thisDate)/(1000*60*60*24);
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:

<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");

05-03-2007, 10:25 AM
Never mind...I got it! :)