Skip to main content
December 9, 2011
Question

Populating A Dropdown List

  • December 9, 2011
  • 1 reply
  • 1069 views

I have a dropdown list that I am trying to populate the values of.

<select name="brokers">

  <cfoutput group="id" query="getDBAGroups">

   <option class="groupName" value="<cfoutput>#brokers_id#</cfoutput>">#name#</option>

     <cfoutput>

       <option class="broker" value="#brokers_id#" <cfif session.statFilter.brokers EQ brokers_id>selected</cfif>>   #fixStringCase(dba)#</option>

     </cfoutput>

  </cfoutput>

</select>

The first option is a group name and each of its members are listed under it (I cannot use optgroup because I need the group to be selectable). The value of this option needs to be a comma seperated list of each of its members. I can get the list to output, but is there a function that will add the commas? I can add the comma to the end of the string and then strip the last one, but here is my second problem. I need the value to show selected if it matches another value.

ie. <cfif session.userBrokerView EQ #valueList#>selected</cfif>

Any thoughts?

    This topic has been closed for replies.

    1 reply

    BKBK
    Community Expert
    Community Expert
    December 9, 2011

    centricCD wrote:

    The first option is a group name and each of its members are listed under it (I cannot use optgroup because I need the group to be selectable). The value of this option needs to be a comma seperated list of each of its members. I can get the list to output, but is there a function that will add the commas?

    You seem to suggest that (a list of) various members share the same brokers_id. Is that true? In any case, how do you get the members? As a query column? how do you arrive at a "list"?

    December 9, 2011

    That is correct. The "group" value is a list of all its members broker_id's, and then each member is listed below it. The member value is its broker_id. The values are coming from a query. I tried valueList(), but it dumps the entire record set, not the ID grouped record set.

    BKBK
    Community Expert
    Community Expert
    December 9, 2011

    centricCD wrote:

    That is correct. The "group" value is a list of all its members broker_id's, and then each member is listed below it.

    That can't be correct. I should make my question clearer. You implied earlier that all members in a group share one(!) broker_id. That one ID appears as the "group" value of the option in the select. However, you're now saying that the group value is a list of IDs.