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/or year and it draws the new calendar. It works fine the
first time I load the page (no form submission) 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). Also after submitting the form the
select menus show the proper month but not the proper year. Any
suggestions? It's running on Windows 2000, IIS 5. 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>