#1
  1. Business Analyst
    Devshed Beginner (1000 - 1499 posts)

    Join Date
    Mar 2004
    Location
    The 'Ville
    Posts
    1,087
    Rep Power
    22

    multiple select list problem


    i have a CFSELECT used in a search that works fine when only one attribute is selected for search... here are the two pieces of code, the first is from the input form, the second is from the SQL search query...

    <CFSELECT name="category" multiple="yes" size="4">
    <OPTION value="">----------
    <CFOUTPUT query="categoryQuery">
    <OPTION value="#Category#">#Category#
    </CFOUTPUT>
    </CFSELECT><br>

    -------------------------------------------------
    SELECT ...
    WHERE
    Category IN('#form.Category#')

    I've tried a few different things, putting the ' 's on the form values, putting them on the SQL query, but the problem is that if multiple values are selected like Cat AND Dog, it submits the value 'Cat,Dog' instead of 'Cat','Dog'... and obviously 'Cat,Dog' is not found in the database...

    Can anyone help? Thanks!!!
    Last edited by mateoc15; April 8th, 2004 at 02:52 PM.
    Discontent is the first necessity of progress. - Edison
  2. #2
  3. Business Analyst
    Devshed Beginner (1000 - 1499 posts)

    Join Date
    Mar 2004
    Location
    The 'Ville
    Posts
    1,087
    Rep Power
    22
    anyone? this is driving me crazy
    Discontent is the first necessity of progress. - Edison
  4. #3
  5. SQL Consultant
    Devshed Supreme Being (6500+ posts)

    Join Date
    Feb 2003
    Location
    Toronto Canada
    Posts
    27,204
    Rep Power
    4279
    try

    Code:
    WHERE Category IN ( #ListQualify(form.Category,"'",",","ALL")# )
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL
  6. #4
  7. Business Analyst
    Devshed Beginner (1000 - 1499 posts)

    Join Date
    Mar 2004
    Location
    The 'Ville
    Posts
    1,087
    Rep Power
    22
    thanks... sometimes it's just a matter of knowing about the existence of a particular function... that works great...

    thanks again
    Discontent is the first necessity of progress. - Edison
  8. #5
  9. No Profile Picture
    Moderator

    Join Date
    Jun 2002
    Location
    Raleigh, NC
    Posts
    5,273
    Rep Power
    968
    You could also try:

    listChangeDelims( list, "','", "," )

    but listQualify() is a bit more elegant.

IMN logo majestic logo threadwatch logo seochat tools logo