Print Page | Close Window

If problem

Printed From: Web Wiz Forums
Category: General Discussion
Forum Name: Classic ASP Discussion
Forum Description: Discussion on Active Server Pages (Classic ASP).
URL: https://forums.webwiz.net/forum_posts.asp?TID=14257
Printed Date: 30 March 2026 at 3:03pm
Software Version: Web Wiz Forums 12.08 - https://www.webwizforums.com


Topic: If problem
Posted By: ub3rl337ch3ch
Subject: If problem
Date Posted: 15 March 2005 at 6:21pm

I've been having trouble with getting an if statement to work. What I want to do is if one of three options is true, then do something.

I have tried if "x=1 or x=2 or x=3 then" which only seems to read as "if x=1 then" for some reason. I have also tried "if x=1 then ... else if x=2 then... else if x=3 then" which has the same result. What i am trying to do when one of them is true is display a datasheet written mostly in html with a bit of asp.

Is there some kind of error in the syntax i'm using? it doesn't actually give me any errors, it just does nothing if x=2,3.



Replies:
Posted By: dj air
Date Posted: 15 March 2005 at 6:37pm
<%

if (X=1 OR X =2 OR X=3) then
%>
wriote code or datasheet

else write error message

<% END IF %>


that should work, the if x=1 or x=2 or x=3 then should have also worked really im not sure why not.


Posted By: ub3rl337ch3ch
Date Posted: 16 March 2005 at 5:39pm
what i have is an if statement within a form, which basically means that it displays the value of certain records in a series of field, then you either edit, copy or decline the record which is selected by a radio button. the frm itself posts back to itself, and the value of a field that is changed depending on which button you press to submit the form determines what the script does (ie copy the record, decline it (effectively delete) or open a new part of the program to edit it). The copying and deleting works fine, but when it comes to reloading the page, i want to display the same recordset by default. However, when i come back to the page driectly after having copied or deleted, there is nothing, not even the result of the else (which is designed for when no qualifier has been given by the user by which to select the records)
 
ok, here's the code for my if statement:
 
<%
if (pascheck = 14 OR pascheck = 13 OR pascheck = 7) then
fmCL = Request.Form("ClName")
sql = "SELECT PropDate, FarmName, fmPropNo, status FROM BRProp WHERE status='Proposal Not Submitted' AND fmCL='" & fmCL & "'"
vrec.open sql, adoCon
Do WHILE NOT vrec.EOF
%>
   <tr>
    <td width="15">&nbsp;</td>
    <td width="20"><font face="Arial">
    <input type="radio" value="<%Response.Write vrec("fmPropNo")%>" name="radio"></font></td>
    <td width="92"><font face="Arial">
    <input type="text" name="PropNo_<%Response.Write vrec("fmPropNo")%>" value="<%Response.Write vrec("fmPropNo")%>" size="12" READONLY></a></font></td>
    <td width="148"><font face="Arial">
    <input type="text" name="notsure_<%Response.Write vrec("fmPropNo")%>" value="<%Response.Write "Broadacre"%>" size="20" READONLY></font></td>
    <td width="246"><font face="Arial">
    <input type="text" name="FarmName_<%Response.Write vrec("fmPropNo")%>" value="<%Response.Write vrec("FarmName")%>" size="37" READONLY></font></td>
    <td width="106"><font face="Arial">
    <input type="text" name="PropDate_<%Response.Write vrec("fmPropNo")%>" value="<%Response.Write vrec("PropDate")%>" size="14" READONLY></font></td>
    <td width="169"><font face="Arial">
    <input type="text" name="status_<%Response.Write vrec("fmPropNo")%>" value="<%Response.Write "Proposal Not Submitted"%>" size="24" READONLY></font></td>
   </tr>
<%
vrec.MoveNext
loop
%>
  </table>
  <div style="position: absolute; width: 100px; height: 38px; z-index: 1; left: 858px; top: 40px" id="cliform2a">
   <p align="center">
   <button type="submit" value="Edit<BR>Proposal" name="cont1" onMouseDown="window.document.cliform2.cont.value='cliform2Edit'">Edit<BR>
   Proposal</button></p>
   <p align="center">
   <button type="submit" value="Decline" name="cont2" onMouseDown="window.document.cliform2.cont.value='cliform2Decline'">Decline</button></p& amp; gt;
   <p align="center">
   <button type="submit" value="Copy" name="cont3" onMouseDown="window.document.cliform2.cont.value='cliform2Copy'">Copy</button></div>
<%
else
%>
   <tr>
    <td width="15">&nbsp;</td>
    <td width="20"><font face="Arial">
    <input type="radio" value="" name="radio"></font></td>
    <td width="92"><font face="Arial">
    <input type="text" name="PropNo" value="" size="12" READONLY></a></font></td>
    <td width="148"><font face="Arial">
    <input type="text" name="notsure" value="" size="20" READONLY></font></td>
    <td width="246"><font face="Arial">
    <input type="text" name="FarmName" value="" size="37" READONLY></font></td>
    <td width="106"><font face="Arial">
    <input type="text" name="PropDate" value="" size="14" READONLY></font></td>
    <td width="169"><font face="Arial">
    <input type="text" name="status" value="" size="24" READONLY></font></td>
   </tr>
  </table>
  <div style="position: absolute; width: 100px; height: 38px; z-index: 1; left: 858px; top: 40px" id="cliform2a">
   <p align="center">
   <button value="Edit<BR>Proposal" name="cont1">Edit<BR>
   Proposal</button></p>
   <p align="center">
   <button value="Decline" name="cont2">Decline</button></p>
   <p align="center">
   <button value="Copy" name="cont3">Copy</button></div>
<%
end if
%>
 
the pascheck variable is defined earlier in the script (as in before any html) as:
 
if check = "cliform2Decline" then
pascheck = 13
end if
 
if check = "cliform2Copy" then
pascheck = 14
end if
 
where check  is a holder for request.form("cont") - the value that the onmousedown changes (and it does because there is other script that runs earlier in the piece if pascheck is 13 or 14. pascheck = 7 is just when you first load that part of the program.
 
The thing that's  getting me is that it works when passcheck = 7, but not when pascheck = 13 or 14... the ifthen to set pascheck is working, but for some reason it seems not to want to recognise pascheck at that point in my code... and don't ask me to post the entire code because there's just under 1400 lines thus far... :p


Posted By: Gullanian
Date Posted: 16 March 2005 at 7:16pm
At a quick glance syntax looks fine.  Just print out the value of x to ensure it's giving you it's expected values.



Print Page | Close Window

Forum Software by Web Wiz Forums® version 12.08 - https://www.webwizforums.com
Copyright ©2001-2026 Web Wiz Ltd. - https://www.webwiz.net