title: AJAX list categories and subcategories in a select - Wordpress
body: <p>I want to create a dynamic load for categories, for example, there is the "Countries" category, then "USA", "Brazil", "Spain" on a subcategory and "New York", "Rio de Janeiro" and "Barcelona" at a sub-sub-category.</p>
  
  <p>Like this 
  America [USA(New York), Brazil(Rio)] ; Europe [Spain(Barcelona)]</p>
  
  <p>So I have 3 selects: First one the user would have to select "America" or "Europe", then if I choose "America" the second one loads "Brazil" and "USA" for me to choose and so on.</p>
  
  <p>What I'm trying is to use the <code>wp_dropdown_categories</code> function and dynamically populate the next <code>wp_dropdown_categories</code> choices, based on the current choice with the <code>child_of</code> atribute. </p>
  
  <p>I tried doing something with the javascript above to get the option chosen for the first one and it worked, but I can't see a way to populate the other select dynamically, like making a <code>wp_dropdown_categories</code> child_of, like this <code>wp_dropdown_categories('child_of=the_category_i_have_chosen');</code></p>
  
  <pre><code>&lt;script type="text/javascript"&gt;
      var dropdown = document.getElementById("cat");
      function onCatChange() {
          var value = dropdown.options[dropdown.selectedIndex].value
          }
      }
      dropdown.onchange = onCatChange;
  &lt;/script&gt;
  </code></pre>