Support

Account

Home Forums Backend Issues (wp-admin) Dynamically populate select field based on sibling selection

Unread

Dynamically populate select field based on sibling selection

  • Currently I have a select field that is dynamically populated based on the contents of a repeater set in an options page. It’s working great. Now I’d like to get a little more advanced.

    The repeater in the options page also contains a nested repeater. What I would like to do is dynamically populate a second select field with the contents of the repeater associated with the selection made in the first select field.

    I assume the only way I’ll be able to dynamically change the second select field based on the first selection is with jQuery. I think I can manage that. What I need some help with is setting up the values so that I can interact with them. Here’s the general structure of the parent repeater object:

    
    array(2) {
      [0]=>
      array(2) {
        ["brand"]=>
        string(5) "Brine"
        ["models"]=>
        array(2) {
          [0]=>
          array(1) {
            ["model"]=>
            string(3) "RP3"
          }
          [1]=>
          array(1) {
            ["model"]=>
            string(9) "Blueprint"
          }
        }
      }
      [1]=>
      array(2) {
        ["brand"]=>
        string(7) "Warrior"
        ["models"]=>
        array(2) {
          [0]=>
          array(1) {
            ["model"]=>
            string(5) "Evo 4"
          }
          [1]=>
          array(1) {
            ["model"]=>
            string(7) "Rabil X"
          }
        }
      }
    }
    

    Anyone have thoughts on how to do this? Thanks!

Viewing 1 post (of 1 total)

The topic ‘Dynamically populate select field based on sibling selection’ is closed to new replies.