HTML and CSS Reference
In-Depth Information
To write the calendar days:
◗
1.
Below the last comment in the writeCalDays() function, add the following com-
mands as shown in Figure 12-26:
var totalDays = daysInMonth(calendarDay);
for (var i = 1; i <= totalDays; i++) {
// Move to the next day in the month
day.setDate(i);
weekDay = day.getDay();
if (weekDay == 0) document.write(“<tr>”); // start a new row on
Sunday
document.write(“<td class='calendar_dates'>” + i + “</td>”);
if (weekDay == 6) document.write(“</tr>”); // end the row on
Saturday
}
Figure 12-26
writing table cells for each day in the month
Next, you'll call the writeCalDays() function from within the calendar() function
and view the results.
◗
2.
Scroll up to the calendar() function and then insert the following statements as
shown in Figure 12-27:
// Write the calendar days
writeCalDays(calDate);