Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP General > Form Doesn't Work Properly

Reply
Thread Tools

Form Doesn't Work Properly

 
 
Mike
Guest
Posts: n/a
 
      12-21-2003
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 = 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 "&nbsp;"
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>
 
Reply With Quote
 
 
 
 
Evertjan.
Guest
Posts: n/a
 
      12-21-2003
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.

So:

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.


--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Form script won't work properly in IE N. Demos Javascript 5 03-17-2005 09:57 PM
Themes do not work properly Matthias Magnold Firefox 3 01-28-2005 01:46 PM
webservice client doesn't work properly jacksu MCSD 0 02-24-2004 04:38 PM
volkswagen.de web-page doesn't work properly with Mozilla Firebird Danilo Silva Firefox 4 10-18-2003 03:46 PM
More American Graffiti: Properly Framed, Properly Scored? Scot Gardner DVD Video 0 09-02-2003 02:28 AM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57