Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Can't determine variable in IF statement 1

Status
Not open for further replies.

Billybonga

IS-IT--Management
Jun 22, 2002
72
GB
Hi all,

I have a strange issue with an if statement.
In a page i have done an include to and external file variables.inc

In this file i have an asp statement
Code:
<% max_questions = 9 %>
</code>

In my vote page I have an If statement :

[code]
             <form action="cast.asp?ID=<%=lAnketID%>" method="post">
               <% if lAnketID = max_questions then %>
                <table border="0" cellspacing="1" cellpadding="2" width="98%" bgcolor="#ffe4b5">
                  <tr> 
                    <td colspan="3" class="header2"><%=sSurveyQuestion%> </td>
                  </tr>
                  <tr> 
                    <td colspan="3" class="smalltext"> <textarea name="comments" cols="70" rows="5" id="comments"></textarea></td>
                  </tr>
                  <tr> 
                    <td width="48%" height="25" align=right> <input type="reset" name="Reset2" class="flatbutton" value="Clear"> 
                    </td>
                    <td width="3%" align=right>&nbsp;</td>
                    <td width="49%" align=right><div align="left"> 
                        <input type="submit" name="cmdOyVer2" value="Submit" class="flatbutton">
                      </div></td>
                  </tr>
                </table>
                <%else%>
                <table border="0" cellspacing="1" cellpadding="2" width="98%" bgcolor="#ffe4b5">
                  <tr> 
                    <td colspan="3" class="header2"><%=sSurveyQuestion%><span style="font-size:10.0pt;font-family:Arial"> 
                      </span></td>
                  </tr>

What is happening is it is unable to determine if lAnketID = max_questions and so shows you the else.

To test that the max_questions variable is being passed i have added a response.write max_questions in various places of the page and it displays that max_questions is 9

lAnketID is also correct as if I change the code to
<% if lAnketID = 9 then %>

everything works fine?


Can anyone see where things might be failing ?

Cheers,

Billybonga
 
Nope because you haven't shown where lAnketID comes from originally.

as you point out setting it to a numeric 9 works but what is it if not set explicitly

If, as I would anticipate (as you are passing it in a querystring) it comes from a querystring it will be a string and unless you are casting to a numeric [lAnketID = Cint(lAnketID)] first, "9" <> 9

Chris.

Indifference will be the downfall of mankind, but who cares?
Woo Hoo! the cobblers kids get new shoes.
People Counting Systems

So long, and thanks for all the fish.
 
Hi Chris,

Thanks for your help,
You would be correct in saying that the lAnketID is coming from a querystring as this is a the question ID from the database which is pulled using a web-address like :


so this page would show question 9

Can you see any way around this ?
The reason what I have max_questions as a variable as I was having problems determining the last question in the database and having it as a variable on a single makes it easier to change in future.

I'm a bite confused when you discribe :
[lAnketID = Cint(lAnketID)] first, "9" <> 9
 
Cheers Chris ,

I figured out what you mean about : lAnketID = Cint(lAnketID)

Many thanks for your help, it works perfectly

Billybong
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top