Skip to main content
May 11, 2010
Question

Strategery

  • May 11, 2010
  • 2 replies
  • 487 views

Hola coldfusion folks.

Currently I have a related selected in a form that calls a cfc.  The state dropdown populates a city dropdown and it works fantasticallizationally.  (Thanks Mr. Forta)

However, I now need to add a country dropdown to the form.  Gulp.  I want to have cities dynamically populated by the country dropdown IF the country selected is not the United States.  Can someone help?

My initial thought was that I should use a cfdiv that either shows states and cities if country is US else just how cities if country is not US.

Thanks!!!

(Also, thank you to everyone who has helped/answered me in the past.  I'm not very good about coming back to update the forums but more often than not you guys help me out.)

    This topic has been closed for replies.

    2 replies

    May 12, 2010

    Ok I decided on a short term solution but am still interested in a long term approach for this as I'll be repeating this same kind of thingamadoo over and over.

    What I did was put the Country dropdown as the first field in the form and made it a javascript jump menu.  If the user selects U.S. it refreshes the form with the state/city cfc.  Otherwise the form queries cities based on the country selected.

    This works just fine but like I said I'm most interested in a way to do this with cf9 ajax (or cfdiv).

    Inspiring
    May 11, 2010

    I suggest forget about the divs and showing/hiding etc for now.  Look at the code you have for related selects.  Create a set for country and state.  Then expand that for state and city.  Once you have all that working, then worry about what the user sees.

    May 12, 2010

    Hi Dan.

    Well here's what I ran into by doing that....

    The cities depend on the state dropdown... however, if I'm selecting a different country, the state dropdown is not applicable, meaning the cities need to depend on the country instead.

    So that brings me back to my initial logic.

    I did try the cfdiv and inside of it tried to do a related select but got a bizzarre "error processing javascript "...

    Inspiring
    May 12, 2010

    When you tried it, what did you have in the "state" select when you selected a country other than the states?

    Also, does your data structure support what you are trying to accomplish?