I want to get the value of the id from this associative array when the value of the drop down changes. This of course is coming from a WordPress function. I’m able to do this fine, but then I want to take that value which I’m getting with js and set the value in a following associative array. How do I get that variable Country in the $State associate array? I believe that normally only takes a string?
<ul class="AdventureFiltersUl list-inline" onchange="myFunction()">
<li class="col-lg-3 col-md-3 col-sm-6 col-xs-12">
<p> Country </p>
<?php $Country = array(
'show_option_all' => '',
'show_option_none' => '',
'option_none_value' => '',
'orderby' => 'name',
'order' => 'ASC',
'show_count' => 0,
'hide_empty' => 1,
'child_of' => 84,
'exclude' => '',
'echo' => 1,
'selected' => 0,
'hierarchical' => true,
'name' => 'cat',
'id' => 'Country2',
'class' => 'postform',
'depth' => 1,
'tab_index' => 0,
'taxonomy' => 'category',
'hide_if_empty' => false,
'value_field' => 'term_id',
); ?>
<!-- Get the Value of the currently selected item -->
<script>
function myFunction() {
var Country = document.getElementById("Country2").value;
}
</script>
<?php $State['child_of'] = $Country; ?>