Sending Output to a Web Page
With the Year variable assigned a value, you can use the document.write() method to display this value on the Web page, as follows:
document.write("Today is 10/15/02<BR>");
document.write("Only 71 days until Christmas");
In your program for Just Plain Stupid, you'll be working with dates as you try to calculate the number of days remaining until December 25th.
var Today = new Date("October, 15, 2002");
var ThisDay = Today.getDate();
var ThisMonth = Today.getMonth() +1;
var ThisYear = Today.getYear();
Edit the line that reads document.write("Today is 10/03/01<BR>"); to read:
|document.write("Today is "+ThisMonth+"/"+ThisDay+"/"+ThisYear+"<BR>");|
Continue to key in the following lines directly below the last line entered above:
//Get number of days until Christmas
var DaysLeft = 999;
Edit the line that reads document.write("Only 71 days until Christmas"); to read:
document.write("Only " + DaysLeft + " days until Christmas");
Save you changes and view them in your browser. The text not only is hard to see, but it needs to aligned to the center.
Save your changes and then view them in your browser. The heading and center alignment commands should appear above the beginning script tag. Don't forget to place a closing H2 tag at the end of the script tag.