Lenny247
Lenny247

Reputation: 19

coldfusion 9 check against multiple variables and any combination valid

I have an if statement and I want to check against multiple variables, but I want any combination of the variables are valid.

<cfif var1 AND OR var2 AND OR var3>
   execute
<cfelse>
   NO
</cfif>

Update from comments:

The variables return boolean values

Upvotes: 1

Views: 165

Answers (1)

Matt Busche
Matt Busche

Reputation: 14333

you would just use OR and exclude using AND If var1 var2 or var3 were true then your code would execute

If var1 is a boolean then saying var1 is accurate

If var1 is a string you would check len(trim(var1))

If var1 is a number you would check var1 GT 0

<cfif var1 OR var2 OR var3>
   execute
<cfelse>
   NO
</cfif>

Upvotes: 5

Related Questions