Skip to main content
Inspiring
April 20, 2015
Answered

How to import an array into a dropdown list?

  • April 20, 2015
  • 1 reply
  • 680 views

I'm very new to ColdFusion and learning things as I go.  I'm wondering how to import an array into a dropdown list.  I created the array and the dropdown but can't get it to work properly.  I would like to see a quick example.

Please help thanks...

    This topic has been closed for replies.
    Correct answer EddieLotter

    The following is a very simplistic example. Please lookup each tag in the documentation to see how they can be used:

    <cfset aOptions = ArrayNew(1)>

    <cfset aOptions[1] = "one">

    <cfset aOptions[2] = "two">

    <cfset aOptions[3] = "three">

    <select id="cbdlComboboxDropdownList" name="cbdlComboboxDropdownList">

    <cfoutput>

    <cfloop array="#aOptions#" index="OptionItem">

    <option>#OptionItem#</option>

    </cfloop>

    </cfoutput>

    </select>

    Sorry for the formatting issues.

    Cheers

    Eddie

    1 reply

    EddieLotter
    EddieLotterCorrect answer
    Inspiring
    April 20, 2015

    The following is a very simplistic example. Please lookup each tag in the documentation to see how they can be used:

    <cfset aOptions = ArrayNew(1)>

    <cfset aOptions[1] = "one">

    <cfset aOptions[2] = "two">

    <cfset aOptions[3] = "three">

    <select id="cbdlComboboxDropdownList" name="cbdlComboboxDropdownList">

    <cfoutput>

    <cfloop array="#aOptions#" index="OptionItem">

    <option>#OptionItem#</option>

    </cfloop>

    </cfoutput>

    </select>

    Sorry for the formatting issues.

    Cheers

    Eddie

    Inspiring
    April 21, 2015

    Thank you so much for the example.  Worked out perfect.