HTML and CSS Reference
In-Depth Information
4. Insert the following code to run the calendar() function to create the table, as
shown in Figure 12-5:
<script type=”text/javascript”>
calendar();
</script>
Figure 12-5
calling the calendar() function
locat ion of the
calendar table
5. Close the file, saving your changes.
6. Open ccc.htm in your Web browser, and then verify that the browser does not
report any coding errors. As Figure 12-6 shows, the calendar table shows only the
table border because the table doesn't contain any content yet.
Figure 12-6
empty table inserted into the web page
embedd e d table
Trouble? Depending on your browser, you might not see the table border, and you
might instead see only a blank space where the Web table would appear.
Next, you'll start to write the code to create the contents of the calendar table. The three
main tasks to complete the calendar table are:
• Create the table header row.
• Create the table row containing the names of the days of the week.
• Create the rows containing the days of the month.
In this session, you'll learn how to create the header row for the calendar table. In the
next session, you'll complete the rest of the table.
Introducing Arrays
Maria wants the header row of the calendar table to display the text Month, Year , where
Month is the name of the month and Year is the four-digit year value. In the last tutorial,
you learned that you can use the getMonth() method of the JavaScript Date object to
extract a month number and the getFullYear() method to extract the four-digit year
value. For example, a Date object storing the date March 18, 2015 has a month value
Search WWH ::




Custom Search