Professional Web Applications Themes

Noob Ques Comma delimited list - Coldfusion - Getting Started

Using this code on my action page, I'm getting three numbers like 133. <cfset stopNumber = ListLen(#attributes.questionID#)> <CFLOOP INDEX="i" FROM="1" TO="#stopNumber#" STEP=1> <cfoutput>#form["ResponseID#i#"]#</cfoutput> </CFLOOP> How can I create a list variable from those numbers? I'd like to wind up with a variable like "test" equal to 1, 3, 3. The reason I'm trying to do this is I need to get those 3 numbers inserted into a table and I think that I can do it from a list but I don't know how to do it otherwise. Thank you....

  1. #1

    Default Noob Ques Comma delimited list

    Using this code on my action page, I'm getting three numbers like 133.

    <cfset stopNumber = ListLen(#attributes.questionID#)>

    <CFLOOP INDEX="i" FROM="1" TO="#stopNumber#" STEP=1>
    <cfoutput>#form["ResponseID#i#"]#</cfoutput>
    </CFLOOP>


    How can I create a list variable from those numbers?
    I'd like to wind up with a variable like "test" equal to 1, 3, 3.

    The reason I'm trying to do this is I need to get those 3 numbers inserted
    into a table and I think that I can do it from a list but I don't know how to
    do it otherwise. Thank you.




    Winston2 Guest

  2. #2

    Default Re: Noob Ques Comma delimited list

    What does your insert query look like? Are you sure you really need a list ?

    ...
    <CFSET test = "">
    <CFLOOP INDEX="i" FROM="1" TO="#stopNumber#" STEP=1>
    <CFSET test = ListAppend(test, form["ResponseID"& i])>
    </CFLOOP>

    <CFOUTPUT>#test#</CFOUTPUT>

    mxstu Guest

  3. Moderated Post

    Default Re: Noob Ques Comma delimited list

    Removed by Administrator
    Winston2 Guest
    Moderated Post

  4. #4

    Default Re: Noob Ques Comma delimited list

    Maybe I'm not clear on your form structure, but instead of passing the
    questionID's as a list ... wouldn't it be easier to store the questionID's in
    the form, the same way you store the responseID's?

    form.question1
    form.response1
    form.question2
    form.response2
    ....

    Then you could just loop from 1 to the #numberOfQuestions# and insert each
    record

    -- Psuedo code
    INSERT INTO SC_UserAnswer
    (..., QuestionID, ResponseID)
    VALUES(..., #FORM["questionID"& loopCounter]#, #FORM["responseID"&
    loopCounter]# )


    mxstu Guest

Similar Threads

  1. Comma delimited array into DB problems
    By Arne de Booij in forum ASP Database
    Replies: 3
    Last Post: August 10th, 04:28 PM
  2. query against comma delimited field
    By cfquest in forum Coldfusion - Advanced Techniques
    Replies: 6
    Last Post: June 10th, 07:28 PM
  3. comma delimited list problem
    By Shaun Perry in forum Macromedia Flash Actionscript
    Replies: 1
    Last Post: February 16th, 12:09 PM
  4. Splitting Comma delimited list
    By Colin Johnstone in forum PERL Beginners
    Replies: 10
    Last Post: December 30th, 04:01 AM
  5. generate CSV or comma delimited
    By shank in forum ASP
    Replies: 4
    Last Post: July 9th, 04:00 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not 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