Skip to main content
Inspiring
March 5, 2009
Question

Making a multiple select dynamic

  • March 5, 2009
  • 3 replies
  • 901 views
I have a multiple select that I would like to make dynamic. I have a look table and a query, but I am not sure how to change the static code into one that pulls the names from the look up table. The form also is used to update and that is where I am not sure how to make it both work on the select. Below is my static code:

select
NIC_Integration_ID,NIC_Txt
from
#request.app.DB#.NAR_NIC_Integration
order by NIC_Integration_ID
</cfquery>

<div>select all that apply</div>

<select name="NIC_Int_DataSeries" multiple>
<option value="Supervisory" <cfif #ListValueCountNoCase(NIC_Int_DataSeries, "Supervisory")# IS 1>selected</cfif>>Supervisory</option>
<option value="Financial" <cfif #ListValueCountNoCase(NIC_Int_DataSeries, "Financial")# IS 1>selected</cfif>>Financial</option>
<option value="Structure" <cfif #ListValueCountNoCase(NIC_Int_DataSeries, "Structure")# IS 1>selected</cfif>>Structure</option>
<option value="Documents Profiles"<cfif #ListValueCountNoCase(NIC_Int_DataSeries, "Documents Profiles")# IS 1>selected</cfif>>Documents Documents Profiles</option>
</select>

Thanks,
Shearak
    This topic has been closed for replies.

    3 replies

    Known Participant
    March 6, 2009
    Use code similar to this... Refer to your

    <cfquery name="stateNames" datasource="mydb">
    SELECT StateName
    FROM dbo.StateFips
    ORDER BY StateName ASC
    </cfquery>

    <select name="stateList" size="18" multiple class="listBox">
    <cfoutput query="mydb">
    <option value="#stateNames.StateName#"
    <cfif Listcontains(url.stateList, #stateNames.StateName#) GT 0> selected="selected"</cfif>
    > #stateNames.StateName#
    </option>
    </cfoutput>
    </select>
    Inspiring
    March 5, 2009
    I'd use checkboxes.
    Inspiring
    March 5, 2009
    If you ever get it to work, it will be very very user unfreindly in that it will be to easy for the user to accidentally de-select all the pre-selected items.

    But, it's your app. To get started, use cfoutput with a query attribute to generate your option tags.
    shearakAuthor
    Inspiring
    March 5, 2009
    What would be your method? I am using the same form to insert and update that field.

    Is this what you had in mind.

    <cfoutput query="GetDataSeries" group="NIC_Txt">
    <option value="#NIC_Txt#"<cfif #ListValueCountNoCase(NIC_Int_DataSeries, "#NIC_Txt#")# IS #NIC_Integration_ID#>selected</cfif>>#NIC_Txt#</option>
    </cfoutput>

    Thanks again,