Entering listbox values into database

Ask a Question related to Coldfusion Database Access, Design and Development.

  1. #1

    Default Entering listbox values into database

    Let's say I'm using SESSION variables to create a form-based wizard (it has 12
    steps, and therefore 12 pages to the wizard). Some of the values the user
    enters/selects/checks (or whatever depending on the form control) will go to
    certain tables and other values will go to other tables.

    OK, in step 6 of the form wizard the user has to select from a list of
    locations that the new program they are entering is offered. Let's say they
    select 'Anchorage' and 'Fairbanks'. Now, in the page that processes the form,
    one of the <cfquery> INSERT INTO statements inserts the program name and
    location for each of the locations selected in step 6 into a table called
    Location_Cross_Reference. For each location I want to insert the name of the
    program as well as ONE of the locations listed on the list. So, if there were 5
    locations selected, then I would want this program name to be entered into that
    table 5 times, each time with a different location.

    I'm imagining this would incorporate some sort of <cfloop> mechanism, but
    having tested it out in various ways I keep getting errors. For example, I
    tried setting the <cfloop index="i" list="#SESSION.ProgWiz.Location#"> code
    before the INSERT INTO statement (but after the <cfquery> tag, with the end of
    the <cfloop> coming after the VALUES() statements. However when I do this the
    SQL to the MS Access database tries to enter a program name and BOTH locations
    each time it loops. :disgust;

    What am I doing wrong?

    S./

    sage703 Guest

  2. Similar Questions and Discussions

    1. Quick Help Please: Null Values in Listbox
      I have a list box populated with values from a ColdFusion query, and following each real value in the listbox, there are unselectable "null" values,...
    2. entering data into MS Access database
      Hello, I'm creating an online survey using XHTML -- no PHP -- where the data will be entering into a MS Access database, and I am having trouble...
    3. Multiple select listbox values in query
      I have two listboxes, the first of which is an autopostback=true that allows multiple row selection. When I select multiple values (by holding down...
    4. Most efficient way of entering data into a SQL database
      Sorry this isn't necissarily ASP, but it is VBScript & ADO and I figure that you all would be the best to ask. I am using a VBScript that reads a...
    5. Adding custom values and database values to DropDwonList
      The other way is to create a DataTable, put the --None-- as the first Row, then read the datareader into the DataTable, and append the --other-- at...
  3. #2

    Default Re: Entering listbox values into database

    If SESSION.ProgWiz.Location is a comma delimited list of locations, then you
    need to put the CFQUERY inside the loop:

    <!--- psuedo code --->
    <cfloop list="#SESSION.ProgWiz.Location#" index="currLocation">
    <cfquery .... >
    INSERT INTO Location_Cross_Reference (Location, ...)
    VALUES ( #currLocation#, ....)
    </cfquery>
    </cfloop>

    Note: You may need to put single quotes around #currLocation# if [Location] is
    a "text" column.



    mxstu 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