Home Forums ACF PRO Populate drop-down from another drop-down


Populate drop-down from another drop-down

  • Hi,

    I have a form with a drop-down (multi-select) which populates from a taxonomy. The user chooses one or more options from this list, then has to choose a primary option in a second single-select drop down.

    How can I populate the second drop down with the selected values from the first? I’ve tried a few JS examples which seem to use repeaters, but couldn’t get any to work.

    Many thanks in advance.

  • Doing this will be fairly complicated. I do not know of any examples for doing this exactly but there are some examples of other cases available of the web if you do a google search for acf populate seclect field based on another field

    I can give you a rough outline of what you need to do.

    The first step will be to use an acf/prepare_field filter to dynamically populate the choices for the second select field based on the first field. This is necessary so that if there is a currently selected value that this value is include in the available choices. Without this step the selected choice will be un-selected when the page is reloaded.

    The second thing you will need to do is add custom JavaScript to ACF. Your script will need to have a action that fires when the first field is changed and update the available options in the second field.

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

You must be logged in to reply to this topic.