Keep up the good job with not smoking, its hard as hell, but well worth it
:-)

  _____  

From: Cutter (CF-Talk) [mailto:[EMAIL PROTECTED]
Sent: Sunday, January 04, 2004 12:31 AM
To: CF-Talk
Subject: Re: Match to list item

Tim,

Thanks, that is exactly what I was looking for. I did look up the
functions by category in LiveDocs, but I missed the difference I guess
(10 hours at work on a Saturday night and 3 days without a smoke after
22 years can do that to you). I've never been able to find CF function
defs in the DW docs, only CF tag reference (and HTML, and JS, and...), I
must be missing something.

I'm not entirely new to CF and SQL, but I'm still rounding out some very
rough edges. Can someone explain a "link table", how it works and what
it does for me?

Cutter

Tim Heald wrote:
> Try listFind() instead.  If that doesn't work you'll need to do a list
loop
> to directly compare the values.  It should work though.  I believe that
> listContains will find sub-strings, which would mean that's expected
> behavior.
>
> You should really be doing this with a link table that contains the id of
> the item, and then the color id.  Shouldn't store lists in a field.
>
> Also so you know CF Studio and Dreamweaver both contain excellent CFML
> documentation.  You can look up functions by type (in this case list)
>
> Tim
>   -----Original Message-----
>   From: Cutter (CF-Talk) [mailto:[EMAIL PROTECTED]
>   Sent: Saturday, January 03, 2004 9:56 PM
>   To: CF-Talk
>   Subject: Match to list item
>
>   I've got a table that stores details about apparel items. One of these
>   fields contains a list of numbers. These numbers correspond to the IDs
>   of various colors in a different table (Example: tblItem.txtColors for
>   specific ID = 1,3,4,7 = Black,Green,Yellow,Brown).
>
>   I have an editor which easily inputs each item into my database. I use a
>   multiselect box to pick my colors (the options are drawn from the colors
>   table and listed alphabetically). My issue comes with my form to edit
>   existing entries.
>
>   The edit form looks almost exactly like the add form with the values of
>   the record already showing in the respective input boxes. Sort of. I'm
>   probably doing this wrong, but I populate my multiselect options with a
>   query of the colors table:
>
>   <cfquery name="qColor" datasource="#variables.DSN#">
>   select intBoutColorID as ID,
>   txtColor as Color
>   from tblBoutColor2
>   order by txtColor
>   </cfquery>
>
>   But then I need to select the colors that are already on record for that
>   item. Since the value in the field looks like a list (1,3,7,9) I looked
>   for a function to find a value in a list. I thought I could use
>   listcontains, but ran into a small issue:
>
>   <select name="color" class="boxes" multiple size="5">
>   <option value=""<cfif qItem.Colors lt 1> selected</cfif>>- No Color
>   Needed -</option>
>   <cfoutput query="qColor">
>   <option value="#qColor.ID#"<cfif
>   listcontains(qItem.Colors,qColor.ID,",") gt 0>
>   selected</cfif>>#qColor.Color#</option>
>   </cfoutput>
>   </select>
>
>   Even though I identified the delimiter (although a comma is the default)
>   it still gives me a small problem with the IDs. If my value list is
>   (23,24 = Tan, Grey) then it actually selects 2,3,4,23,24 (that's a few
>   extra colors the item doesn't come in). I can't seem to get an exact
>   match for the list items.
>
>   Should I be using a different function? Is there a better, easier way to
>   accomplish this? Any help is greatly appreciated.
>
>   Cutter
>
  _____
[Todays Threads] [This Message] [Subscription] [Fast Unsubscribe] [User Settings]

Reply via email to