<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

-----Original Message-----
From: Alan Bleiweiss [mailto:[EMAIL PROTECTED]
Sent: Thursday, May 06, 2004 4:16 PM
To: CF-Talk
Subject: Problem only showing swatches if list contains a swatch name

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 = "">     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="" 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>
[Todays Threads] [This Message] [Subscription] [Fast Unsubscribe] [User Settings]

Reply via email to