Skip to main content
Participant
July 7, 2008
Question

Populating List Boxes

  • July 7, 2008
  • 1 reply
  • 520 views
Azadi – Thanks for your HELP on my last problem. – This is the Old Dog Playing a Young persons game! And loving It! Using CF8 and MySQL 5
New?? List Boxes, or drop-down Combo list Boxes, could you or someone direct me in the proper direction for information on how to Populate a list box or combo box based on the input of the previous list box?? Example Enter From Selection - Southern Gulf Coastal States - All the State in the Southern Gulf Coast would populate the next combo box, and select a State and all the Coastal Cities would be of choice and next after cities is the Zip.
I know how to do it in MS Access not sure the best way to attack this in cf8.
Thanks
    This topic has been closed for replies.

    1 reply

    Inspiring
    July 7, 2008
    There are many ways to do this:
    1. By submitting your data to cf server first and query only according to user selection then populate the target fields according to query.

    2. By querying all data and use javascript variables/arrays/structures to populate your combo box everytime user change the selected item.

    3. By incorporating Ajax to your CF application.


    The first one is the easiest one. But everytime you make changes to your selection, your app submits to cf server which is kind of slow 'cause you have to submit everytime selection changes.

    The second one is by querying all the data, which is slow at first 'coz even the unnecessary data are returned. That is, I don't think the user would try to select all the selections one by one, but rather maybe just select one item. Though, it will be faster already when the user selects another item. This way, your form doesn't have to be re-submitted 'coz you let a javascript variable/arrays/structures store the data at first query.

    The third one(kind of a mix of both 1 and 2), which is the most efficient way among the three to achieve your goal, needs learning Ajax which is going to take a few of your time. But if you know it already, you can let it work well with CF8.

    Anyway, a simple sample code for the first method is attached:
    Inspiring
    July 9, 2008
    The first option above requires another hit to the server, so it's not very easy on the user.

    You can download a custom tag called 'TwoSelectsRelated.cfm', which is widely available and it's free. I think I got mine from the CF Developer's Exchange (does that still exist?). Jus google it, it's easy to find - and it works fine.

    Hope this helps.

    Carlos