What's the best way to create chained select forms with coldfusion? For instance, I have a REGIONS table, ... say they have East coast, central, mountain, and pacific. Say each has a REGION_ID number. Then, I have a STATES table, with each US state with a STATE_ID, REGION_ID, and STATE_NAME. Finally, I'd have a STATE_DETAILS table. With STATE_ID, and other fields with info on the state. The SQL is simple for pulling states for each region. But i'd like it done with chain selects. So, there'd be a drop down menu with the REGIONS. Once one is selected, I would like another drop down form to populate with all the states in that region. Upon clicking on a state, I'd like that state's information to display AUTOMATICALLY. Any recommendations for best implementation of this?
I think you will need javascript or DHTML to make this work. You will still use cfml to dymanically generate the information for your select list but You will need something like this: http://www.dynamicdrive.com/dynamicindex16/chainedselects/index.htm This is an example of what you are looking for and you can download the script for free. Then you can try to integrate cfml into this script to make it doo what you wish.
But can I really populate dynamic content into a .js file with CF code? I thought it would need to be a .cfm file for this to work? Do you know of anywhere to get free script to do this strictly in CF,... maybe with a custom tag?
You might also do a search on ColdFusion Related Selects. There are various incarnations of an old tag called CF_TwoSelectsRelated floating around that do this. The original version used javascript. There are also newer versions that use ajax or flash. http://projects.nateweiss.com/nwdc/workcode.htm http://www.forta.com/blog/index.cfm/2007/5/31/ColdFusion-Ajax-Tutorial-2-Related-Selects http://www.asfusion.com/blog/entry/multiple-selects-related-flash-cfform
If you are using ColdFusion 8, it natively supports bindable selects. Personally I prefer to roll my own ajax just for the sheer flexibility, but I have seen some nice uses of dependent select boxes. Here is a tutorial by Ben Forta: Apparently I cannot add links yet, but go to forta.com and then go to /blog/index.cfm/2007/5/31/ColdFusion-Ajax-Tutorial-2-Related-Selects