469,645 Members | 1,127 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,645 developers. It's quick & easy.

Form Doesn't Work Properly


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.

<%@ Language=VBScript %>
<% Option Explicit %>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">



<body topmargin="0" leftmargin="0" bgcolor="#FFFFFF" text="#000000"
marginwidth="0" marginheight="0">


'declare variables
Dim currentYear, firstDay, currentDate, currentMonth, i, y, start,

if (Request.form("themonth")) then
currentMonth = Request.form("themonth")
currentMonth = Month(Date)
end if
if (Request.form("theyear")) then
currentYear = Request.form("theyear")
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">
<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 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>"
<input type="submit" name="submit" value="Go">

'draw calendar

For i=1 to 42
Response.Write "<td>"
if(Month(currentDate)<>currentMonth) or (i < firstDay) then
Response.write "&nbsp;"
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


Jul 19 '05 #1
1 2060
Mike wrote on 21 dec 2003 in microsoft.public.inetserver.asp.general:
if (Request.form("themonth")) then

A request.form ALWAYS exist, if not entered it is an empty string.


if Request.form("themonth") <> "" then

The parentheses are not needed and just add execution overhead.

In fact this is enough:

if Request.form("themonth") > "" then

because no string can be smaller, in (V)basic terms, than an empty string.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
Jul 19 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

4 posts views Thread by Alex Sibilev | last post: by
27 posts views Thread by Chris | last post: by
11 posts views Thread by Rik | last post: by
3 posts views Thread by Ralph | last post: by
13 posts views Thread by Edwin Smith | last post: by
26 posts views Thread by Jerim79 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.