Dynamic dropdown menus with wp_dropdown_categories

Hi! I have created three dropdown menus with three levels of categories, as seen on:

http://stilius.se/wilink/.

What I need to do is to get only the children of the chosen category in the next menu. For example, if i choose "Örebro", I only want the next menu to show the direct childen of "Örebro", that will be "Karlskoga". If i then choose Karlskoga, I want the next menu to show only "Kläder". Then when I search, I would like to see the posts under that category. Here is my code so far:

<form action="<?php echo home_url( '/' ); ?> method="get" id="searchform" >

<?php $LANargs = array(
'show_option_all' => '',
'show_option_none' => '',
'orderby' => 'ID',
'order' => 'ASC',
'show_count' => 0,
'hide_empty' => 1,
'child_of' => 0,
'exclude' => '',
'echo' => 1,
'selected' => 0,
'hierarchical' => 1,
'name' => 'cat',
'id' => '',
'class' => 'postform',
'depth' => 1,
'tab_index' => 0,
'taxonomy' => 'product_category',
'hide_if_empty' => false
); ?>

<?php wp_dropdown_categories( $LANargs ); ?>

<?php $STADargs = array(
'show_option_all' => '',
'show_option_none' => '',
'orderby' => 'ID',
'order' => 'ASC',
'show_count' => 0,
'hide_empty' => 1,
'child_of' => 0,
'exclude' => '',
'echo' => 1,
'selected' => 1,
'hierarchical' => 1,
'name' => 'cat',
'id' => '',
'class' => 'postform',
'depth' => 2,
'tab_index' => 0,
'taxonomy' => 'product_category',
'hide_if_empty' => false
); ?>

<?php wp_dropdown_categories( $STADargs ); ?>

<?php $KATEGORIargs = array(
'show_option_all' => '',
'show_option_none' => '',
'orderby' => 'ID',
'order' => 'ASC',
'show_count' => 0,
'hide_empty' => 1,
'child_of' => 0,
'exclude' => '',
'echo' => 1,
'selected' => 1,
'hierarchical' => 1,
'name' => 'cat',
'id' => '',
'class' => 'postform',
'depth' => 3,
'tab_index' => 0,
'taxonomy' => 'product_category',
'hide_if_empty' => false
); ?>

<?php wp_dropdown_categories( $KATEGORIargs ); ?>

<input type="submit" class="submit" name="submit" id="searchsubmit" value="<?php esc_attr_e( 'Sök', TEMPLATE_DOMAIN ); ?>" />

</form>

Is it maybe possible to do this via the Javascript onSelect function, or use a function in the child_of value? Any point in the right direction would be helpful.

Thanks!

/Stilius

  • Jack Kitterhing
    • Code Norris

    Hi there @Stilius

    I hope you are well today.

    I've checked out your site, this menu what it does it link to? Standard WordPress posts, pages, products, something else?

    As it would most likely be a little easier if you had a menu bar with a drop down for the child menu items, Or will this be some sort of directory? Where need to choose say a country that shows a county that shows a town?

    Thanks!

    Kind Regards
    Jack.

  • Stilius
    • Design Lord, Child of Thor

    This is thought to be a directory for my MarketPress products. Therefore I use another taxonomy. As you said, it would be used for filtering the products in my site based on state, city and type of business (In swedish). I would like it to function with the standard Wordpress search to find the products.

  • Jack Kitterhing
    • Code Norris

    Hi there @Stilius

    I hope you are well today, first of all I apologize about the extreme delay here, somehow I missed your last response and have only just seen this while going through some older tickets.

    I'm very sorry about this, I believe the following may be of help http://www.jquery4u.com/plugins/10-jquery-selectboxdrop-down-plugins/ specifically number 4, which is the chain select.

    I'm of course more than happy to assist further and again sorry for the extreme delay.

    Kind Regards
    Jack.

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.