Problem combing multiple lists into one

Ask a Question related to Macromedia ColdFusion, Design and Development.

  1. #1

    Default Problem combing multiple lists into one

    I have three lists (m1,m2,m3) and I need to combine them into one list (m4):

    <cfset m1 = valuelist(search2.cat)>
    <cfset m2 = valuelist(search2.cat2)>
    <cfset m3 = valuelist(search2.cat3)>

    <cfset m4 = m1 & m2 & m3 >
    <cfset m4 = listsort(m4,"text")>

    That works fine but some of the values are mixed up.

    List One = A, B, C
    List Two = D, E, F
    List Three = G, H,I

    Combined List = A, B, CD, E, FG, H, I

    The Value C get added to the next line D, and value F gets added to the next
    line G.
    How can I separate end values of each list?

    mourning2night Guest

  2. Similar Questions and Discussions

    1. Running a query with multiple lists
      Any help would be so appreciated, I have beat my head against the wall on this one and have scoured the web trying to find an answer. I am trying...
    2. writing content of multiple lists to db
      I have a time reporting app that contains five elements, staff, date, CR (job) category (activity) and hrs. Since each staff person can work...
    3. 'or' selection from multiple lists
      Hey, I am trying to set up a selection where a user can choose from one or multiple drop downs and choose as many within a box as they want. ...
    4. problem with lists
      I have the following code in test1.cfm with a struct that work just fine... <cfloop index="ind" from="1" to="#miQuery.recordcount#"> <tr> <cfset...
    5. lists, attaching behaviour dynamiclly, update lists
      Hello, I am trying to get these scripts to work correctly. What I am trying to do is: 1) Look into a folder called 'tank,' then when this is...
  3. #2

    Default Re: Problem combing multiple lists into one

    What you need to do, instead of just concatenating them together, is use
    ListAppend.

    If you change:
    <cfset m4 = m1 & m2 & m3>
    to
    <cfset m4 = ListAppend(m1,ListAppend(m2,m3))>
    then you'll be good to go.

    A list in ColdFusion is just a glorified string. m1 just contains "A,B,C", so
    when you do the concatenation (&), coldfusion doesn't have any idea that you
    actually want it to put a list separator in between the 2 lists ("strings")
    that you are concatenating.

    Kronin555 Guest

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139