Multiple select box to populate another select box

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • fishctr
    New Member
    • Feb 2008
    • 8

    Multiple select box to populate another select box

    Hi There,
    I am creating a survey that asks users what countries they have worked in, and which regions in those countries. Because there can be many answers, I was thinking I could populate a multiple select box, using php and mysql, containing the countries. When the user selects a country, another select box containing the regions in that country would appear (using Javascript onchange event handler).

    My problem is that since multiple countries can be selected, multiple secondary select boxes must be created for several onchange events. I am thinking that I should use another event handler for this one, maybe onclick. Or I should just scratch my idea of creating boxes dynamically and use JS to validate that the region selected is in a country that has also been selected?

    Any ideas?
  • fishctr
    New Member
    • Feb 2008
    • 8

    #2
    I decided to go with checkboxes instead and use the onclick event handler to display the drop down choices.

    Thanks,

    Comment

    • hsriat
      Recognized Expert Top Contributor
      • Jan 2008
      • 1653

      #3
      Originally posted by fishctr
      I decided to go with checkboxes instead and use the onclick event handler to display the drop down choices.

      Thanks,
      You took a good decision. That would look better than select box and would be easier for JavaScript.

      Comment

      • acoder
        Recognized Expert MVP
        • Nov 2006
        • 16032

        #4
        One other way you could do it is to have a single select box which populates a single region select box and the user can select countries/regions one by one which appear as text (which can be removed if need be).

        Comment

        Working...