Home Forums General Issues Conditional Select Values


Conditional Select Values

  • Hi,

    is it possible, with or without custom coding, to populate a dropdown with values, conditionally?

    I am trying to use ACF to provide country and region selection.

    I want to have one dropdown for countries and one for regions (which will display only the regions in the selected country).

    The only way I can see to achieve this, is to create a dropdown for each country, and put that country’s regions into it (and show each region dropdown conditionally depending on the country dropdown’s selected value). This of course is not feasible, as I would end up with a zillion form fields to manage. Also, it’s not very semantic and would cause problems when having a front-end search form to find things in a region).

    I would create a Select, in the ACF form fields, and put all the countries in it. I want to be able to create just one other select, put all regions in it, and somehow associaite each region with a country (so that only the regions belonging to a country are shown, when that country is selected eitehr in the backend or in a front end form).

    is this simple enough?


  • I think you would have to make the country drop down then various region drop downs that are conditional to a selection in the country drop down.

  • Hi @dancosinedev-co-uk

    Thanks a lot for reaching out to us.

    Whatever you are trying is possible but with custom coding.

    You will need to implement a custom AJAX function that will load the field values for the regions once the country selected changes.

    I hope this helps.

  • Here is an example of loading one select field based on a choice made in another select field. This uses custom post types to populate the fields, but the values could come from other sources.

Viewing 4 posts - 1 through 4 (of 4 total)

The topic ‘Conditional Select Values’ is closed to new replies.