473,406 Members | 2,849 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

Form Doesn't Work Properly

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 "&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>
Jul 19 '05 #1
1 2234
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)
Jul 19 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Tyler Style | last post by:
Hullo - looking for a little advice here. I have a form on a page in one domain submitting to a cgi in another domain. Weirdly, on some Windows XP systems, a form on the page fails to submit/post...
4
by: Alex Sibilev | last post by:
Hello, I have a really weird problem I've been trying to solve it without any luck for the last couple of hours :( I'm writing a "conference board" application (quite similar to ASP.NET...
27
by: Chris | last post by:
Hi, I have a form for uploading documents and inserting the data into a mysql db. I would like to validate the form. I have tried a couple of Javascript form validation functions, but it...
11
by: Rik | last post by:
Hello guys, now that I'm that I'm working on my first major 'open' forms (with uncontrolled users I mean, not a secure backend-interface), I'd like to add a lot of possibilities to check wether...
0
by: neonspark | last post by:
I'm buidling some simple macro functionality for my app so the users can record a sequence of keyboard inputs and replay them reliably via some menu. Originally, I used: protected override bool...
3
by: Ralph | last post by:
Hi I have small function to generate my form controls: function buildInput(sType, vValue, vId, sName, sLabel){ var oInput = null; var oLabel = document.createElement('label'); var oCont =...
13
by: Edwin Smith | last post by:
I have a form which displays a DataGridView table generated with the VS2005 tools. The database is a Pervasive v.9 with an ODBC driver. The DataGridView works great except when I'm done and I...
26
by: Jerim79 | last post by:
I need to create a form that takes a number that the user enters, and duplicates a question the number of times the user entered. For instance, if the customer enters 5 on the first page, when...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.