Copy link to clipboard
Copied
I heard that there is a better way than doing this, can anyone tell me? Thanks you!
<CFIF (st_addr["City"] NEQ "Ohio") OR (st_addrs["City"] NEQ "San Jose")>
Copy link to clipboard
Copied
Where'd you hear that?
Copy link to clipboard
Copied
Hard to say anything without some context. What is st_addr? Where does that line show up in your code? Is there a cfelseif or cfelse tag as well?
Copy link to clipboard
Copied
If st_addr and st_addrs are meant to be the same, i.e. there's a typo in the example, ... then in your case,
<CFIF (st_addrs["City"] NEQ "Ohio") OR (st_addrs["City"] NEQ "San Jose")>
is just without a point, since it will always produce a TRUE result with any values of st_addrs["City"].
The value is always either not "ohio" or not "san jose".
-Fernis
Copy link to clipboard
Copied
<cfif "Ohio,San Jose" Does Not Contain st_addrs["City"]>
Does it with a single compare and is very readable; if that's what your after that is...
Copy link to clipboard
Copied
> <cfif "Ohio,San Jose" Does Not Contain st_addrs["City"]>
> Does it with a single compare and is very readable; if that's what your after that is...
This would not work properly, since it does a string comparison, not a list item comparison.
<cfif "New York,Boston" does not contain "York"> would be a true condition.
Use NOT ListContainsNoCase() instead.
-Fernis
Copy link to clipboard
Copied
Yes, it's true that the list does not contain the value. OP seems to have lost interest, with info provided this returns desired result.
Copy link to clipboard
Copied
The below is also one of the possible way..
<cfset cityList="Ohio,San Jose">
<cfif ListFindNoCase(cityList,st_addrs["City"])>
................
................
................
</cfif>
Copy link to clipboard
Copied
Amiya,
Oh yes, definitely prefer ListFindNoCase instead of ListContains, that was what I meant, but misthought it somehow 🙂 Otherwise I would've just corrected a wrong example with another wrong example
-Fernis