This content has been marked as final. Show 8 replies
Your problem may be here:
CONTAINS- "Determines whether the value on the left is contained in the value on the right. Returns true if it is."
This is a quote from the CF docs. In your case, the value on the left is the 3-element list othercolornames. Try reversing the order.
You are right, something is not right with "CONTAINS" in that code.
the order cannot be controlled and it can be various. actually, variables.othercolorname is user's selections. If i use "EQ" instead of "CONTAINS", it does not work. please help
this is crazy. if the form.colorname has values of 21,27,97, it selected
9,2,21,27,97 from values in test01 query. HELP!!!!!!
>this is crazy. if the variables.othercolorname has values of 21,27,97, it selected
>9,2,21,27,97 from values in test01 query. HELP!!!!!!
>I've tried list function, but it did not work for me
The results are right, but I think you're misunderstanding the contains function. It sounds like you should be using a list function instead. What do you mean when you say the list functions "did not work for me"?
it should be only selected "21,27,97" and not "9 and 2" since i set the values of "21, 27, 97" for form.colorname.
Also, I tried <cfif form.colorname contains ValueList(bqry01.index_id)> instead of w/o valuelist. Then when i submit the form, none of the values was selected. I think i used wrong expression. The pick list should be the same value which was set in form.colorname.
P.S Sorry for using a different variable scoop. variables.othercolorname has been changed to form.colorname.
Rather than using CONTAINS, do the following:
<CFIF ListFind(form.colorname, test01.index_id)>selected</CFIF>
Contains will return true if one string contains another string. The expression below will output YES because the string "21,27, 97" contains the string " 9". This is not the right type of comparison for what you're trying to achieve.
<cfif "21,27,97" CONTAINS "9">
To determine whether the value "9" is contained within a list of values, use list functions like ListFind or ListFindNoCase:
<cfif listFind("21,27,97", "9") gt 0>
thank you so much, jedline and cf_dev2. thanks agin cf_dev2 for the kind explanation of "CONTAINS".