
The only difference between this ASP file & the HTML
file:
This example demonstrates how easy it is to transition from Client-Side JavaScript to Server-Side JavaScript. <HTML> <% /********** DECLARE ARRAYS & DATE OBJECT **********/ var dayName = new Array
("Sunday", "Monday", "Tuesday",
"Wednesday", var Month30 = new Array(3, 5, 8, 10); //
months containing 30 days var now = new Date(); /********** END OF DECLARE ARRAYS & DATE OBJECT **********/ /********** CHECK QUERY STRING **********/ // if the Request("Month")
doesn't exist then get current Month // if the Request("Year")
doesn't exist then get current Year /********** END OF CHECK QUERY STRING **********/ /********** GET FIRST DAY OF MONTH **********/ var strDate = new Date(Year, Month, 1); // set Date for the 1st of the selected Month var firstDay = strDate.getDay(); // get the Date of the 1st Day of the selected Month function getDaysInMonth(Year,
Month) { /* for (variable in [object | array]) Checking to see if the Month has 30
days // Checking to
see if the Month has 31 days var daysInMonth = getDaysInMonth(Year, Month); // gives us the number of days in the Month /********** END OF GET FIRST DAY OF MONTH **********/ %> </HEAD> <BODY> <% // variables to be
used for the arrows Response.write('<H2>'); /********** LEFT ARROW **********/ // if Month <=
0 then we are going from Jan to Dec & the Year is one year less // create left
linked arrow, ie, calendar.htm?Month=12&Year=1999 /********** END OF LEFT ARROW **********/ /********** WRITE OUT MONTH & YEAR **********/ Response.write(' ');
// 2 spaces
between Left Arrow & Month and Year /********** END OF WRITE OUT MONTH & YEAR **********/ /********** RIGHT ARROW **********/ // if Month >=
0 then we are going from Dec to Jan & the Year is one year more // create right
linked arrow, ie, calendar.htm?Month=2&Year=2000 /********** END OF RIGHT ARROW **********/ Response.write('<H2>'); %> <TABLE> <% /********** TABLE HEADER **********/ // Create Table
Headers (Sunday, Monday, etc..., Saturday) Response.write("</TR><TR>"); /********** END OF TABLE HEADER **********/ /********** BODY OF THE TABLE **********/ var column = firstDay; //
first day of the Month // fill up the
Beginning of the Month of to the 1st of the Month with Blank Cells for (i = 0; i < daysInMonth;) { // fill up the End
of the Month after the Last of the Month with Blank Cells /********** END OF BODY OF THE TABLE **********/ %> </TR></TABLE> </CENTER> </BODY> |