Thursday, March 24, 2011

What is the best way to do a simple Parent-Child drop down in pure Javascript

I need to do a quick and dirty 'Country' --> 'State' drop down relationship on a web form. I only am concerned with the states, provinces, and territories for USA and Canada, and this will be a relatively lightly used form, so a pure javascript solution is probably ideal.

From stackoverflow
  • Create a JSON array:

    array = [ { name: "United States", states: [...] }, { ... } ];
    

    When the value of the dropdown changes, fill in the other drop down with the contents of the particular element from the array.

0 comments:

Post a Comment