Hi,
I'm new to ASP and can't get this form to work. It's a simple page
that draws a calendar for the current month and then you can select a
new month and it draws the new calendar. It works fine the first time
I load the page but doesn't work when I submit the form. It doesn't
seem to be properly evaluating the first if statement for drawing the
calendar but all the variables seem to be correct (i.e. it it using
the values passed from the form). Any suggestions? It's running on
Windows 2000. The code is below. Thanks in advance.
Mike
<%@ Language=VBScript %>
<% Option Explicit %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Calendar</title>
</head>
<body topmargin="0" leftmargin="0" bgcolor="#FFFFFF" text="#000000"
marginwidth="0" marginheight="0">
<%
'declare variables
Dim currentYear, firstDay, currentDate, currentMonth, i, y, start,
finish
if (Request.form("themonth")) then
currentMonth = Request.form("themonth")
else
currentMonth = Month(Date)
end if
if (Request.form("theyear")) then
currentYear = Request.form("theyear")
else
currentYear = Year(Date)
end if
currentDate = DateSerial(currentYear, currentMonth, 1)
firstDay = Weekday(currentDate)
%>
<table border="0" cellpadding="0" cellspacing="0" width="100%">
<form action="calendar.asp" method="POST">
<tr>
<td colspan="7" align="center">
<select name="themonth">
<option value="1" <% if (currentMonth = 1) then Response.write "
selected" %>>January</option>
<option value="2" <% if (currentMonth = 2) then Response.write "
selected" %>>February</option>
<option value="3" <% if (currentMonth = 3) then Response.write "
selected" %>>March</option>
<option value="4" <% if (currentMonth = 4) then Response.write "
selected" %>>April</option>
<option value="5" <% if (currentMonth = 5) then Response.write "
selected" %>>May</option>
<option value="6" <% if (currentMonth = 6) then Response.write "
selected" %>>June</option>
<option value="7" <% if (currentMonth = 7) then Response.write "
selected" %>>July</option>
<option value="8" <% if (currentMonth = 8) then Response.write "
selected" %>>August</option>
<option value="9" <% if (currentMonth = 9) then Response.write "
selected" %>>September</option>
<option value="10" <% if (currentMonth = 10) then Response.write "
selected" %>>October</option>
<option value="11" <% if (currentMonth = 11) then Response.write "
selected" %>>November</option>
<option value="12" <% if (currentMonth = 12) then Response.write "
selected" %>>December</option>
</select>
<select name="theyear">
<%
start = currentYear - 1
finish = currentYear + 3
for y=start to finish
Response.write "<option value=""" & y & """"
if (y = currentYear) then Response.write " selected"
Response.write ">" & y & "</option>"
next
%>
</select>
<input type="submit" name="submit" value="Go">
</td>
</tr>
</form>
<tr>
<td>Sunday</td>
<td>Monday</td>
<td>Tuesday</td>
<td>Wedenesday</td>
<td>Thursday</td>
<td>Friday</td>
<td>Saturday</td>
</tr>
<tr>
<%
'draw calendar
For i=1 to 42
Response.Write "<td>"
if(Month(currentDate)<>currentMonth) or (i < firstDay) then
Response.write " "
else
Response.write Day(currentDate)
end if
Response.write "</td>"
if (i mod 7)="0" Then
Response.write "</tr>"
end if
if (i >= firstDay) Then
currentDate=dateAdd("d", 1, currentDate)
end if
Next
%>
</table>
</body>
</html>