Populating Drop Down Boxes from a database

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

  1. #1

    Default Populating Drop Down Boxes from a database

    We moved our wesite from a Box running Coldfusion 4.0 to a box running
    Coldfusion MX. We populate some drop down boxes with information from a
    database table that has 10 Fields. Each of the fields are independant from
    each other. Some of the fields have 40 rows of information - while some fields
    only have 3 rows of information. I run my Query to bring in all my information
    from the table using (*). When I go to my drop down boxes - I will get 37 rows
    of NOTHING for the fields where I want to display only 3 rows of stuff. I use
    the CFSelect command to populate the drop down boxes. Under ColdFusion 4.0 -
    only the rows that had data were displayed - now all 40 rows are displayed -
    even the ones with no data. Help! Do I need to change my Query or do I need
    to make a change to my CFSelect command?

    gskar Guest

  2. Similar Questions and Discussions

    1. Typing for Drop Down Boxes
      Basically you know when you have a drop down box and you type a letter the drop box automatically goes to an item beginning with that letter. But...
    2. Populating Drop-down menu with unused numbers
      I have 2 tables, plans and renters, that are joined by plan_id. Plan_id is the primary key of my apartments, which is called aptNumber, in the...
    3. 2 dynamic drop down boxes from database
      I'm populting one box from a table called category. I want to create another box that would be populated subcatagories from the subcategory table...
    4. Populating three list boxes from the database
      Can anybody help? I need to have three list boxes automatically populating each other, (ie when region is selected from the first listbox, it will...
    5. Populating several combo boxes
      I have a form that will have a combo box repeated several times (continuous form, one for each record), it's going to cause a problem if each has to...
  3. #2

    Default Re: Populating Drop Down Boxes from a database

    You may want to try the following: 1. Use query-of-query on the main query to
    crate separate ones to be used for each of your cfselects. In the q-of-q make
    sure you only select rows that have data. or 2. Instead of passing the query
    attribute to cfselect, use a cfloop and a conditional if to ouput the option
    tags. Best of luck

    Azeem Guest

  4. #3

    Default Re: Populating Drop Down Boxes from a database

    Azeem is right. It is best to to a cfloop over the query. Do your query, then
    loop it as such: <select name='fieldname'> <cfloop query='queryname'> <cfif
    queryname.value IS 'whateveryouwant'>
    <option><cfoutput>#queryname.value#</cfoutput></option> </cfif> </cfloop>
    </select>

    Abinidi Guest

  5. #4

    Default Re: Populating Drop Down Boxes from a database

    The suggestions I got were GREAT - I got it to work. NOW I need one more bit
    of help if possible. Within the options in my Drop Down Boxes I need to select
    one of them as the DEFAULT. Before I used the CFLoop command it did work - the
    SELECTED option worked - now it does not. Any help would be appreciated.
    Below is the code: LEAD2 is the value of my default which is one of the options
    from the drop down box LOOP statement. <CFSELECT name='lead7' size='1'
    selected='#Lead2#'> <cfloop query='QueryTableSeries3'> <cfif
    QueryTableSeries3.Lead IS NOT ''> <option>
    <cfoutput>#QueryTableSeries3.Lead#</cfoutput> </option>
    </CFIF> </cfloop> </CFSELECT>

    gskar Guest

  6. #5

    Default Re: Populating Drop Down Boxes from a database

    You haven't got a VALUE parameter on the OPTION perhaps that is what the CFSELECT SELECTED attribute uses to determine which option to mark as selected.

    <OPTION VALUE="#QueryTableSeries3.Lead#">


    zoeski80 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