Skip to main content
September 8, 2008
Question

CFIF EQ more than one value?

  • September 8, 2008
  • 2 replies
  • 3918 views
What is the syntax to do a CFIF variables.value EQ value1 or value2, or value3, etc. without saying
<CFIF variables.value EQ value1 OR variables.value EQ value2 OR variables.value EQ value3>

I simply do not know where to look. I tried IN [value1,value2, value3} - not right.

Has to be simple.

Thanks.
    This topic has been closed for replies.

    2 replies

    Inspiring
    September 8, 2008
    Assuming you are dealing with basic strings, you could just add quotes around the list of values.

    <cfif listFindNoCase("3,4,6", variables.value)>
    found
    <cfelse>
    not found
    </cfif>

    Though you may prefer to use a separate variable if you have more than a few values.

    <cfset listOfValuesToSearch = "1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19">
    <cfif listFindNoCase(listOfValuesToSearch, variables.value)>
    found
    <cfelse>
    not found
    </cfif>
    Inspiring
    September 8, 2008
    I usually use the listFind or listFindNoCase function:

    <cfif listFindNoCase(listOfValuesToSearch, variables.value)>
    found
    <cfelse>
    not found
    </cfif>
    September 8, 2008
    Thanks but how do I enter a list of (3,4,6) in the istOfValuesToSearch without setting up an array or something.
    Inspiring
    September 8, 2008
    quote:

    Originally posted by: LeeBC
    Thanks but how do I enter a list of (3,4,6) in the istOfValuesToSearch without setting up an array or something.

    Where are the values coming from in the first place?