Support

Account

Home Forums Backend Issues (wp-admin) Dynamically populate a repeater select’s options from adjacent select choice?

Unread

Dynamically populate a repeater select’s options from adjacent select choice?

  • Hi there,

    I’m looking to have the options of one select field dynamically populate based on what is chosen from an adjacent select within a set of nested repeaters. Here’s how it’s structured – for this example consider the format as follows: Name | Type | Key.

    main_rpt | Repeater | field_67b496e1748b4
    -> sub_rpt | Repeater | field_67b49e25083de
    –> sel_car_brand | Select | field_67b4a2d3083e2
    –> sel_car_model | Select | field_67b4a32f083e3

    These fields are shown on a custom post type (let’s say “cars” for this example – key for the group is: group_67b35fb0ba371 and post ID is 61). What I’m looking to do is modify what options show up in “sel_car_model” based on what is chosen for that repeater row’s “sel_car_brand” choice. IE if “Honda” is chosen in the brand select, then the options for the model select could be “fit : Honda Fit” “crv : Honda CR-V” “accord : Honda Accord”, but if you chose “Toyota” it would be populated with say “highlander : Highlander” “cam : Toyota Camry” “cor_hb : Toyota Corolla Hatchback” “cor_hyb : Toyota Corolla Hybrid”, etc.

    I also want to make sure that the sel_car_model field is being populated by just the sel_car_brand field within the current repeater “row”.

    I know it’s shown here just for populating a select field via ajax and other methods, but this is a bit more involved and I’m unsure how to proceed: https://www.advancedcustomfields.com/resources/dynamically-populate-a-select-fields-choices/

    Thanks in advance!

Viewing 1 post (of 1 total)

You must be logged in to reply to this topic.