|
Mailing Lists
|
Home / Groups / ColdFusion Talk (CF-Talk)
Problem only showing swatches if list contains a swatch nameWhen I use this code, I get no match results, and doing a dump shows me that the only list-item in "fullList" is the last item in the original list At 02:25 PM 5/6/04, you wrote: ><cfset >fullList="1.jpg,130.jpg,130A.jpg,130E.jpg,2.jpg,23.jpg,3.jpg,30.jpg"> ><cfset thisList="2,23,23E,30,130,130A,130E"> > ><cfloop list="#thislist#" index="I"> ><cfif listFind(fullList,i & ".jpg")> >#i# ></cfif> ></cfloop> > >Or to make it easier, strip the jpg off the end of the file names in the >full list (if you know they are always jpgs and append that where you're >outputting #i#. > >John Burns > >In a product display page I need to show color swatches based on only >those colors a particular product has available, rather than showing all >color swatches in my swatch image directory. >(Entire code set and table creation code at bottom of this email) > >EXPLANATION: > >I have two lists - > >One is a comma delimited list stored in one field in my database, the >field name is "Colors". Example content: > >2,23,23E,30,130,130A,130E > >The other is a list of files in a directory (using CFDIRECTORY to pull >the >list) >Example content: > >1.jpg,130.jpg,130A.jpg,130E.jpg,2.jpg,23.jpg,3.jpg,30.jpg > >I'm lost as to how to run a comparison on the two lists and bring back >only those JPG files that match the Colors data field. > >And here's what I've done to create a table showing the swatches >I know this is incorrect but don't know how to run my comparison. > ><!-------- >SWATCH DISPLAY PAGE CODE FOLLOWS >-----------> > ><!-------- >QUERY TO GET COLORS for this specific product >-----------> ><CFQUERY NAME="GetProduct" DATASOURCE="#EComDB#"> >SELECT Colors >FROM Products >WHERE SiteID='#SiteID#' >AND ProductUnique = '#PrId#' ></CFQUERY> > ><!---------- >CFDIRECTORY TAG to create list of all swatch images >------------> ><cfdirectory > action = "list" > directory = >"c:\inetpub\wwwroot\briona\firstavenue\sites\cdusa\shop\ColorCharts\Euro >peanNaturals" > name = "GetSwatches" > filter = "*.jpg"> > ><!---------- >SWATCH TABLE DISPLAY CODE FOLLOWS: >------------> ><TABLE BORDER="1"> ><CFSET #count# = 1> ><CFLOOP QUERY="GetSwatches"> ><CFOUTPUT> > ><CFSET ThisName=#Replace(#Name#,".jpg","","ALL")#> > ><!---------- >COMPARE COLORS DATA FIELD TO THIS SWATCH- >THIS IF STATEMENT IS MY PROBLEM, I'M SURE >-------------> ><CFIF #GetProduct.Colors# CONTAINS #ThisName#> > ><!--------- >START A NEW ROW >-----------> ><CFIF #COUNT# EQ 1> ><TR> ></CFIF> > ><TD ALIGN="CENTER" VALIGN="TOP"><IMG >SRC="ColorCharts/EuropeanNaturals/#name#" ALT="#ThisName#"> ><BR> ><FONT SIZE="1" FACE="Arial,Helvetica">#ThisName# ><BR> ><INPUT TYPE="Radio" NAME="MyColorChoice" >VALUE="#ThisName#"></FONT></TD> > ><CFSET #COUNT# = #COUNT# +1> > ><!--------- >END TABLE ROW AFTER 8 CELLS >-----------> ><CFIF #COUNT# GT 8> ></TR> ><CFSET #COUNT# = 1> ></CFIF> > ></CFIF> > ></CFOUTPUT> ></CFLOOP> > ></TABLE> > >---------- >[<http://www.houseoffusion.com/lists.cfm/link=t:4>Todays Threads] >[<http://www.houseoffusion.com/lists.cfm/link=i:4:162466>This Message] >[<http://www.houseoffusion.com/lists.cfm/link=s:4>Subscription] >[<http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=3784.3524.4>Fast >Unsubscribe] [<http://www.houseoffusion.com/signin/>User Settings] > >---------- |
June 19, 2013
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||