% @ LANGUAGE="JScript" %>
<% //___________________________________________________________
//
// URL for more info: www.blazonry.com/scripting/datemenu.php
// File: datemenu.asp
// Date: October 1998
//
// Auth: www.blazonry.com
//
//___________________________________________________________
%>
<%
reqmeth = Request.ServerVariables("REQUEST_METHOD")
if (reqmeth == "POST") {
submitbtn = Request.Form("submitbtn")
dispdate = Request.Form("dispdate")
tmpDate = new Date(dispdate)
if (submitbtn == "<< Prev" ) {
tmpDate = new Date(tmpDate.getFullYear(), tmpDate.getMonth() -2, tmpDate.getDate());
}
else {
tmpDate = new Date(tmpDate.getFullYear(), tmpDate.getMonth() + 2, tmpDate.getDate());
}
} else {
tmpDate = new Date();
}
%>
ASP Calendar Menu
<%
// repeat twice to display previous
// and current month
saywhat = 1;
while (saywhat >= 0) {
today = new Date(tmpDate.getFullYear(), tmpDate.getMonth()-saywhat, tmpDate.getDate());
iMonth =today.getMonth();
sMonth = getDisplayMonth(iMonth);
first = new Date(today.getFullYear(), iMonth, 1);
firstwday = first.getDay();
lastdayofMonth = getLastDayMonth(iMonth);
%>
<%=sMonth+" "+today.getFullYear()%> |
M | T | W | Th | F |
<% d = 1;
wday = firstwday;
firstweek = true;
while ( d <= lastdayofMonth) {
if (firstweek) {
Response.Write("");
for (i=1; i ");
}
firstweek = false;
}
if (wday==0) {
// Sunday write
Response.Write("
");
}
else if (wday==6) {
// Saturday write
Response.Write("
\n");
}
else {
// M-F
Response.Write("" + d + " | ");
}
wday++;
wday = wday % 7;
d++;
}
%>
<%
saywhat = saywhat - 1;
}
%>
Download the source here (datemenu_asp.txt)
<%
function getDisplayMonth(monum) {
monthArray = new Array("January","February","March","April","May","June","July","August","September","October","November","December")
return monthArray[monum];
}
function getLastDayMonth(monum) {
var lday = 0;
now = new Date();
outahere:
for (i=28; i<=32; i++) {
thedate = new Date(now.getFullYear(), monum, i)
if (thedate.getMonth() != monum) {
lday = i - 1;
break outahere;
}
}
return lday;
}
%>