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!

And Statement 1

Status
Not open for further replies.

axLW

Programmer
Feb 6, 2015
110
GB
Code:
<%

var1="w1"
var2="e5"

if var1="w1" or var1="w2" or var1="w3" or var1="w4" or var1="w5" and var2="w1" or var2="w2" or var2="w3" or var2="w4" or var2="w5" then
response.write ("true")
else
response.write ("false")
end if

%>

I only want to display true if var1 is w1 or w2 or w3 or w4 or w5 AND var2 is w1 or w2 or w3 or w4 or w5

You can see above that var1 is w1 (true) but var2 is e5 (false).

So why does the code above display true. Only one of the conditions is being met!?

Can someone help me. It's probably very simple but I don't get it!
 
You need to bracket the ORs with the AND between the bracketed sets

eg;

If (a OR b OR c) AND (d OR e OR f) Then




Chris.

Indifference will be the downfall of mankind, but who cares?
Time flies like an arrow, however, fruit flies like a banana.
Webmaster Forum
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top