Blank Monthly Calendars For

Reviews
Shared by: rockcartwright
Stats
views:
62
rating:
not rated
reviews:
0
posted:
6/29/2009
language:
English
pages:
0
CS1301 Introduction To Computer Programming (08-09 Semester B) www.cs.cityu.edu.hk/~helena PAGE 1 OF 3 WEEK 9 TUTORIAL Monthly Calendar More practices on control structures, Dynamic creation of html table contents Date object and methods In this tutorial, you will create a Monthly Calendar like: Figure 1 Preparation: Download the given html file. The body contains only a header and an empty span:

Monthly Calendar

Step 1. [ We first ASSUME that the month starts on Sunday and has 31 days !!! ] Modify the code to display a row of 31 day numbers in a table, within the days span (See Figure 2). Note - Write a function named showCalendar( ), that sets the html contents of the span. Call this function during onload of the page body. - In showCalendar( ), the 31 cells should be generated using a while-loop. (i) Before and after the while-loop, add and
. (ii) In the loop, if the day is 1 or 31 (ie. row start/end), add and correspondingly. (iii) The days are in the form: 1 2 3 … Figure 2 Step 2. Split the table into rows (see figure 3). Note: In showCalendar( ), add var x; that stands for Sun - Sat : x = 0, 1, 2, .. 6 Sunday Saturday (i) Handle the value of x : … x=0; // Assume first day is Sun while (..) { … At the end of each round, update x to x=..; prepare for next round: } Add 1 to x, if x becomes 7, reset x to 0, (Shortcut: use %) (ii) With the value of x, it is easy to split the table into rows: and st Start a row (Just before showing a Sunday) End of row (after a Saturday or 31 day) Figure 3 CS1301 Introduction To Computer Programming (08-09 Semester B) www.cs.cityu.edu.hk/~helena PAGE 2 OF 3 Step 3. Make Sundays red and bold (see figure 3). Note: Use if-else statement to generate different html code for the cells: check the value of x. Step 4. Ask the user to tell the number of days in the month (28, 29, 30, or 31): Figure 4 Note: Add a variable, totDays, in showCalendar( ) and call the prompt dialog to get its value: var totDays=parseInt(prompt("What is the total number of days in the month?",31)); Change the condition of the while-loop to check totDays. Step 5. Ask the user to tell the weekday of the first day as shown in figure 5. Figure 5 Note: Add a variable, startWeekDay, in showCalendar( ) and call the prompt dialog to get its value: var startWeekDay=parseInt(prompt("What is the weekday of the first day? \n(0: Sun, 1: Mon, etc..)",0)); Given Code Add the createBlankCells(n) function (Figure 6) to your file. This function generates HTML code for n blank cells. We will use it to make the starting blank cells in the calendar: Consider Figure 5: if startWeekDay is 4 (Thur), then there should be 4 blank cells in first row. See? startWeekDay can determine the starting blank cells!! So, in showCalendar( ), just before showing the first day of the month, you can add ..+=createBlankCells(startWeekDay) to create and add the HTML code (blank cells) to the calendar. Also, before the while-loop, the value of x should be set to startWeekDay, not 0. (Review the code and check whatever else is to be modified.) //Create a number of blank cells //based on the argument n function createBlankCells(n) { var i=0; var result=""; while (i
Related docs
Blank Monthly Calendars To
Views: 65  |  Downloads: 0
Free Printable Blank Monthly Calendars
Views: 50  |  Downloads: 0
Printable Blank Monthly Calendars
Views: 68  |  Downloads: 1
Free Blank Monthly Calendars
Views: 103  |  Downloads: 2
Blank Calendars To Print
Views: 50  |  Downloads: 0
Monthly Calendars Print
Views: 9  |  Downloads: 0
blank 2009 calendars
Views: 5  |  Downloads: 0
Blank July Calendars
Views: 2  |  Downloads: 0
Free Monthly Printable Calendars
Views: 458  |  Downloads: 4
Free Printable Blank Monthly Calendar
Views: 29  |  Downloads: 0
Printable Blank Monthly Calendar
Views: 318  |  Downloads: 3
Calendars Free To Print
Views: 0  |  Downloads: 0
Print Free Calendars
Views: 3  |  Downloads: 0
a) Calendars
Views: 14  |  Downloads: 0
premium docs
Other docs by rockcartwright
Loans First Loan Free
Views: 50  |  Downloads: 0
Is An Arm Mortgage
Views: 37  |  Downloads: 0
Loan Calculator For Car
Views: 80  |  Downloads: 0
Loan Interest Calculator Excel
Views: 261  |  Downloads: 10
Loan Interest Only Loan
Views: 73  |  Downloads: 0
Large Printable Monthly Calendar
Views: 964  |  Downloads: 3
Loan Payments In Excel
Views: 131  |  Downloads: 3
Loan Payment Calculator Formula
Views: 1173  |  Downloads: 4
Loan Monthly Payment Formula
Views: 1658  |  Downloads: 7
Loan Calculator Monthly Interest
Views: 387  |  Downloads: 4
Loan Payment Calculator Car
Views: 111  |  Downloads: 0
Loan Amortization Schedule For
Views: 78  |  Downloads: 0
Loan Calculators Interest Only
Views: 96  |  Downloads: 1
Loan Interest Calculation Formula
Views: 332  |  Downloads: 8
Interest Calculator On Savings
Views: 54  |  Downloads: 1