I am looking to code a dynamic drop down list within ColdFusion. What I want is the drop down list to be populated by the above drop down list (example: Select Province (B.C) will populate the City drop down list with all cities within that Province). Province data will be collected from a ColdFusion query and same with the city's data.
0
votes
1 Answers
2
votes
The easiest way is to use CFSELECT binding them with cfc's.
Here's an example:
<cfform name="mycfform">
<!---
The States selector.
The bindonload attribute is required to fill the selector.
--->
<cfselect name="state" bind="cfc:bindFcns.getstates()" bindonload="true">
<option name="0">--state--</option>
</cfselect>
<cfselect name="city" bind="cfc:bindFcns.getcities({state})">
<option name="0">--city--</option>
</cfselect>
</cfform>
The {state} in the second bind is the value of the first CFSELECT. By using CFC's it will repopulate the second select each time the first changes.