<% @ Language="JavaScript" %> Calendar <% var dayName = new Array ("Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday") var monthName = new Array ("January","February","March","April","May","June","July","August","September","October","November","December") var Month30 = new Array(3, 5, 8, 10); var Month31 = new Array(0, 2, 4, 6, 7, 9, 11); var now = new Date(); /********** PARSE SEARCH STRING **********/ var Month = (isNaN(Request("Month"))) ? parseInt(now.getMonth()) : parseInt(Request("Month")) - 1; var Year = (isNaN(Request("Year"))) ? parseInt(now.getYear()) : parseInt(Request("Year")); /********** END OF PARSE SEARCH STRING **********/ /********** GET FIRST DAY OF MONTH **********/ var strDate = new Date(Year, Month, 1); var firstDay = strDate.getDay(); function getdaysInMonth(Year, Month){ if (Month == 1) { if (((Year % 4 == 0) && (Year % 100 != 0)) || (Year % 400 == 0)) return 29; else return 28; } for (month in Month30) { if (Month == Month30[month]) return 30; } for (month in Month31) { if (Month == Month31[month]) return 31; } } var daysInMonth = getdaysInMonth(Year, Month); /********** END OF GET FIRST DAY OF MONTH **********/ %>

Events Calendar

<% var monthL, monthR; var yearL = yearR = Year; /********** LEFT ARROW **********/ Response.write('

'); if (Month <= 0) { monthL = 12; yearL = Year - 1; } else monthL = Month; Response.write(''); Response.write(''); Response.write(''); /********** END OF LEFT ARROW **********/ Response.write('  '); Response.write(monthName[Month] + " " + Year); Response.write('  '); /********** RIGHT ARROW **********/ if (Month >= 11) { monthR = 1; yearR = Year + 1; } else monthR = Month + 2; Response.write(''); Response.write(''); Response.write(''); Response.write('

'); /********** END OF RIGHT ARROW **********/ %> <% /********** TABLE HEADER **********/ for (i = 0; i < 7; i++){ Response.write(''); } Response.write(""); /********** END OF TABLE HEADER **********/ /********** BODY OF THE TABLE **********/ var column = firstDay; var Day = 1; for (i = 0; i < firstDay; i++) { Response.write(''); // beginning blank cells } /********** SET UP CONNECTION & RECORDSET OBJECTS **********/ var adOpenStatic = 3; var adLockOptimistic = 3; var adCmdText = 0x0001; var strDSN = "DRIVER={Microsoft Access Driver (*.mdb)};DBQ=" + Server.MapPath("calendar.mdb") + ";" var nMonth = Month + 1; var strSQL = "SELECT * FROM calendar WHERE Month = " + nMonth + " AND Year = " + Year + ""; var conn = Server.CreateObject("ADODB.Connection"); conn.Open(strDSN); rsCal = Server.CreateObject("ADODB.RecordSet"); rsCal.Open(strSQL, conn, adOpenStatic, adLockOptimistic, adCmdText); /********** END OF SET UP CONNECTION & RECORDSET OBJECTS **********/ for (i = 0; i < daysInMonth;) { if (column++ != 7) { if (now.getMonth() == Month && now.getDate() == Day && now.getYear() == Year) { Response.write(''); } else { Response.write(''); } i++; } else { Response.write(""); column = 0; } } /********** CLOSE & DESTROY ADO OBJECTS **********/ rsCal.Close(); rsCal = null; conn.Close(); conn = null; /********** END OF CLOSE & DESTROY ADO OBJECTS **********/ if (column != 0 && column < 7) { for (i = column; i < 7; i++) { Response.write(''); // ending blank cells } } /********** END OF BODY OF THE TABLE **********/ %>
' + dayName[i] + '
 ' + Day++ + ''); if (!rsCal.BOF) rsCal.MoveFirst(); while (!rsCal.EOF) { if (rsCal.Fields("Day") == Day - 1) { Response.Write('
' + rsCal.Fields("Subject") + '
'); } rsCal.MoveNext(); } Response.write('
' + Day++ + ''); if (!rsCal.BOF) rsCal.MoveFirst(); while (!rsCal.EOF) { if (rsCal.Fields("Day") == Day - 1) { Response.Write('
' + rsCal.Fields("Subject") + '
'); } rsCal.MoveNext(); } Response.write('
 
Month Year