[thelist] ASP If statement gone nuts

Lightening oktellme at earthlink.net
Fri Aug 1 19:14:44 CDT 2003


Below is some code from my calendar program. I also attached it, but don't
know it the attachment will go thru the list.
I took out everything I could to get it down to the errant statements. You
can see my calendar at
www.whitelightening.net/buzzell/calendar.asp

Seems quite crazy to me.

I originally wrote it as a simple IF statement:

    if currentMonth > qsmonth then
         qyear = qyear+1
    end if

This calendar should work for the year ahead of us.
Today it is August 2003. SO... if someone wants to look at September,
October or November, it is presumed they are still looking at 2003. If
someone wants to look at January, it is presumed they want January, 2004.

Therefore, if currentMonth (8 for August) is greater than requested month (1
for January), add 2003 + 1 and get 2004.

Kindergarten level logic, if you ask me. So, where am I going wrong????

No matter what months I requested, this logic never gets executed. When I
switched it ("<"), it ALWAYS executes, and I get 2004 no matter what.

You can see in my logic there are displays everywhere. It doesn't care what
the values are. If I use ">" it ALWAYS finds the condition false. If I use
"<". It always finds the logic true!

I thought maybe my computer was broken, so I put it out on the web (see
above url), to see how it ran under someone else's computer. No change.

The HAS to be something very dumb and obviouis (to everyone else) wrong with
my coding.

Can somebody help?

thanks
Laura


__________________________________________
This is the code:
__________________________________________

<% option explicit %>

<html>
<head>
<title>Calendar</title>
</head>

<body bgcolor="#333399" text="#000000">


<%


dim qsmonth
dim qyear
dim currentMonth


'prepare selected date .... qsmonth is what the user wants to see;
currentMonth is what month it is now
qsmonth=request.querystring("rqmonth")
currentMonth=DatePart("m",date())

if qsmonth < 1 or qsmonth > 12  then
  qsmonth=currentMonth
end if

'prepare dates to draw calendar
qyear=datePart("yyyy",date())



'_______________________________THIS IS PART CAUSING TROUBLE
_______________________________________

' figure out which year to show
response.write "<font color='#ffffff'>  " & currentMonth & " " & qsmonth & "
" & qyear & "</font><br>"
if currentMonth < qsmonth then
 qyear = qyear
 response.write "<font color='#ffffff'>  " & currentMonth & " " & qsmonth &
" " & qyear & "Chose to ignore </font><br>"
else
 qyear = qyear+1
 response.write "<font color='#ffffff'>  " & currentMonth & " " & qsmonth &
" " & qyear & "Chose to add one year</font><br>"
end if

'______________________________________END OF TROUBLE
________________________________________________


%>



<table width="100%" border="2" cellspacing="0" cellpadding="0">
  <tr>
    <td bgcolor="#eeeeee" align="center">
      <h1><font color='#520052'>Calendar</font></h1>
    </td>
  </tr>
  <tr> <td bgcolor="#ccbbff" align="center">
  <form action="calendarQ.asp">
   <table width="100%" border=0><tr>

  <td align="center" width="90%">
  <%  response.write "<h1><font color='#990099'>" & qsmonth & " / " & qyear
& "</font></h1>"%>
  </td>


        <td align="left" alignvert="top" width="14%"> <h3>Select a month
&nbsp;</h3>
            <select name="rqMonth" id="rqMonth">
              <option value="1"   ><h2>January</h2></option>
              <option value="2"   ><h2>February</h2></option>
              <option value="3"   ><h2>March</h2></option>
              <option value="4"   ><h2>April</h2></option>
              <option value="5"   ><h2>May</h2></option>
              <option value="6"   ><h2>June</h2></option>
              <option value="7"   ><h2>July</h2></option>
              <option value="8"   ><h2>August</h2></option>
              <option value="9"   ><h2>September</h2></option>
              <option value="10"  ><h2>October</h2></option>
              <option value="11"  ><h2>November</h2></option>
              <option value="12"  ><h2>December</h2></option>
            </select>

   <input type="submit" value="GO" width="45%">
        </td>


 </tr></table>
 </form>
  </tr>
</table>





</table>
</body>
</html>


More information about the thelist mailing list