Listbox, CFOUTPUT, and CFLOOP

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

  1. #1

    Default Listbox, CFOUTPUT, and CFLOOP

    I'm trying to create a form to update a record. This record is already saved in
    the DB of course, so all the fields already have values. I'm able to have most
    of my listboxes show the value that is currently saved for a record as the
    default. However, I'm unsure how to make a listbox that uses a <cfloop> to loop
    through a list variable to populate the listbox show the value that is saved
    for that record. Here's the code:

    <select name="Location_State">
    <cfoutput>
    <option value=""></option>
    <cfloop list="#states#" index="i">
    <option value="#i#">#i#</option>
    </cfloop>
    </cfoutput>

    For example, if a record has CA saved as the state in question, I want that
    value to show up in the listbox as the currently selected value when you go to
    update the record. The way it is now (see the above code) the blank option is
    the default.

    Anyone familiar with coldfusion forms?

    Thanks,
    S./

    sage703 Guest

  2. Similar Questions and Discussions

    1. concat cfloop index to cfoutput variable inside loop?
      Hi, STUPID question here: I have a cfloop, index j. I have a text field, DESCRIPTION_#j#, inside the loop. I want to populate the VALUE of the...
    2. cfoutput and cfloop
      Hi all, well this is my question: I want to show 2 or more different sets of record sets but one or more of them have to be nested on the first,...
    3. click listbox and refresh another listbox
      Can someone guide me to a resource on building set of drill-down listboxes? Basically I want to have 4 listboxes. The first starts out with...
    4. Item label displays as "," when moving from listbox to listbox
      I have 2 listboxes: "lb_unselected" and "lb_selected". The first thing in the actions is loop through an array populating these two listboxes. ...
    5. now desparate! - 1st listbox contents disappears when 2nd listbox appears?
      On 23 Jun 2003 12:57:45 -0700, KathyBurke40@attbi.com (KathyB) wrote: Its been a while since you posted but I will answer anyway. The problem...
  3. #2

    Default Re: Listbox, CFOUTPUT, and CFLOOP

    ...

    <cfset savedState = "IL">
    <select name="Location_State">
    <cfoutput>
    <option value=""></option>
    <cfloop list="#states#" index="i">
    <option value="#i#" <cfif i eq savedState>selected</cfif>>#i#</option>
    </cfloop>
    </cfoutput>
    </select>

    mxstu Guest

  4. #3

    Default Re: Listbox, CFOUTPUT, and CFLOOP

    Thanks mxstu,

    I actually found another way to do it right after I posted the thread:

    <select name="Location_State">
    <cfoutput>
    <option value=""></option>
    <cfloop list="#states#" index="i">
    <option value="#i#" <cfif programs.Location_State IS
    i>SELECTED</cfif>>#i#</option>
    </cfloop>
    </cfoutput>
    </select>

    sage703 Guest

  5. #4

    Default Re: Listbox, CFOUTPUT, and CFLOOP

    Glad you found your solution. Yes, in CF the IS is synonymous with EQ so the statement "... somevalue IS i" is the same as saying "somevalue EQ i".
    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