Chain selects for coldfusion forms

Discussion in 'Programming' started by lespaul00, Jan 30, 2008.

  1. #1
    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?
     
    lespaul00, Jan 30, 2008 IP
  2. unitedlocalbands

    unitedlocalbands Well-Known Member

    Messages:
    246
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    128
    #2
    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.
     
    unitedlocalbands, Jan 30, 2008 IP
  3. lespaul00

    lespaul00 Peon

    Messages:
    283
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    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?
     
    lespaul00, Jan 31, 2008 IP
  4. cfStarlight

    cfStarlight Peon

    Messages:
    398
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    0
    #4
    cfStarlight, Feb 1, 2008 IP
  5. dshuck

    dshuck Peon

    Messages:
    92
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #5
    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
     
    dshuck, Feb 1, 2008 IP
  6. cfStarlight

    cfStarlight Peon

    Messages:
    398
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    0
    #6
    Or click the second link above ;)
     
    cfStarlight, Feb 7, 2008 IP
  7. dshuck

    dshuck Peon

    Messages:
    92
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #7
    lol... oops.

    Yeah... that link.
     
    dshuck, Feb 8, 2008 IP