Boopathy
Boopathy

Reputation: 46

How can I check two conditions in an if statement?

<%
i=1
j=1

if ((i=1) && (j=1)) then
response.write("i = 1 and j =1")
else
response.write("i <> 0")
end if

%>

I'm saving this with a .asp extension. Here the if condition is not working. How can I check 2 conditions in if condition of classic ASP code?

Upvotes: 1

Views: 13115

Answers (3)

RMK
RMK

Reputation: 456

Try this

if ((i=1) and (j=1)) then

Upvotes: 0

David
David

Reputation: 218828

I think the logical operator you're looking for is And in this case:

if ((i = 1) And (j = 1)) then

Upvotes: 3

meda
meda

Reputation: 45490

The operator is and not && so change your code to:

<%
i=1
j=1

if ((i=1) and (j=1)) then
Response.Write("i = 1 and j =1")
else
Response.Write("i <> 0")
end if

%>


Output:

i = 1 and j =1

Upvotes: 1

Related Questions