WordPress.org

Ready to get started?Download WordPress

Forums

Drop Down Menu/Form Child Category Select (1 post)

  1. motocomdigital
    Member
    Posted 3 years ago #

    Howdy,

    I'm running 2 drop down menu's on my archive page. The drop down menu's pull in the child category's of my specified parent category.

    The bottom menu does not work because of the top one drop down menu.

    If I remove the top drop down, the bottom drop down works perfectly. So I have established they don't work in unison.

    Has anybody got any ideas on how I can tweek these so they both work on the same page?

    The code below

    Top Drop Menu > Pulling in children of category ID 3

    <div action="<?php bloginfo('url'); ?>/" method="get" class="margin-none">
    
    <?php wp_dropdown_categories('show_option_none=Filter by Category&child_of=3&depth=1&orderby=name&show_count=1'); ?>
    
    <script type="text/javascript"><!--
    var dropdown = document.getElementById("cat");
    function onCatChange() {
    if ( dropdown.options[dropdown.selectedIndex].value > 0 ) {
    location.href = "<?php echo get_option('home');
    ?>/?cat="+dropdown.options[dropdown.selectedIndex].value;
    }
    }
    dropdown.onchange = onCatChange;
    --></script>
    </div>

    Second Drop Menu > Pulling in children of category ID 23

    <div action="<?php bloginfo('url'); ?>/" method="get" class="margin-none">
    
    <?php wp_dropdown_categories('show_option_none=Filter by Category&child_of=23&depth=1&orderby=name&show_count=1'); ?>
    
    <script type="text/javascript"><!--
    var dropdown = document.getElementById("cat");
    function onCatChange() {
    if ( dropdown.options[dropdown.selectedIndex].value > 0 ) {
    location.href = "<?php echo get_option('home');
    ?>/?cat="+dropdown.options[dropdown.selectedIndex].value;
    }
    }
    dropdown.onchange = onCatChange;
    --></script>
    </div>

    I'm keen in understanding why. I've tried tweeking but nudda.

    Thanks in advance :-) I will be forever grateful...

    Josh

Topic Closed

This topic has been closed to new replies.

About this Topic

  • RSS feed for this topic
  • Started 3 years ago by motocomdigital
  • This topic is not resolved
  • WordPress version: 3.1.3