[英]classic asp if statement issue
I have a if statement which I am pretty sure it is correct and should work. 我有一个if语句,我可以肯定它是正确的并且应该可以工作。 But for some reason it is not.
但是由于某种原因,事实并非如此。
while not oRs2.EOF
if iCat = oRs2("id") then
%>
<div class ="<%= oRs2("id") %><%= iCat %>">
<%
else
%>
<div class ="faqquestion <%= oRs2("id") %><%= iCat %>">
<%
end if
%>
And this is what you get. 这就是你得到的。
<div class="faqquestion 11">
<div class="faqquestion 21">
<div class="faqquestion 31">
but what it should be 但是应该是什么
<div class="11">
<div class="faqquestion 21">
<div class="faqquestion 31">
cant see what i am doing wrong, 1 does = 1!? 看不到我在做什么错,1 = 1 !?
how the variables are being set: 如何设置变量:
dim iCat
iCat = request.QueryString("cat")
dim sSQL
sSQL = "Select * from table"
set oRs2 = oConn.Execute(sSQL)
I think the problem is one of data typing. 我认为问题是数据键入之一。
For example I tested the following script (just take the contents and put into a file called test.vbs, then double click on it: 例如,我测试了以下脚本(只需将其内容放入一个名为test.vbs的文件中,然后双击它即可:
dim i
i = "1"
dim j
j=1
if i = j then
msgbox "yes"
else
msgbox "no"
end if
msgbox i & j
This will output "no" and "11". 这将输出“ no”和“ 11”。
In your code the iCat will be a string as you're just pulling it from request.QueryString
so try converting it to an integer using CInt
在您的代码中,iCat将是一个字符串,因为您只是将其从
request.QueryString
拉出,因此请尝试使用CInt
将其转换为整数
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.