0

I have looked at all the questions similar to mine and can't seem to figure this out. I am trying to change the information that is presented in one drop down menu when another drop down menu is changed.

Here is what I have:

<div class="dropdown">
    <button class="btn btn-default dropdown-toggle product-dropdown" type="button"
            id="dropdownMenu1" data-toggle="dropdown"
            aria-haspopup="true" aria-expanded="true">
        Product Type
        <span class="caret"></span>
    </button>
    <ul class="dropdown-menu product" aria-labelledby="dropdownMenu1">
        <li><a href="#">Banner</a></li>
        <li><a href="#">Magnet</a></li>
        <li><a href="#">Sticker</a></li>
        <li><a href="#">Decal</a></li>
        <li><a href="#">Yard Sign</a></li>
        <li><a href="#">Digital Print</a></li>
        <li><a href="#">Business Sign</a></li>
    </ul>
</div>

The above dropdown will change this dropdown:

<div class="dropdown">
    <button class="btn btn-default dropdown-toggle option-dropdown" type="button"
            id="dropdownMenu1" data-toggle="dropdown" aria-haspopup="true"
            aria-expanded="true">
        Options
        <span class="caret"></span>
    </button>
    <ul class="dropdown-menu option" aria-labelledby="dropdownMenu1">
        <li><a href="#">test</a></li>
    </ul>
</div>

I want the option title to change, which I have achieved. Also I want the dropdown menu to change.

$(".product li a").click(function() {
    $(".product-dropdown:first-child").html($(this).text() + ' <span class="caret"></span>');
});
$(".product li a").click(function() {
    $(".option-dropdown:first-child").html($(this).text() + " Option's"+ ' <span class="caret"></span>');
});

The above Javascript is working, however I want the second dropdown to be filled with the below information:

var productType = [];
productType["Banner"] = ["Grommets", "UV Protection", "Gloss Finish", "Matte Finish"];
productType["Mangets"] = ["Rounded Corners", "UV Protection", "Contour Cut"];
productType["Sticker"] = ["Contour Cut", "UV Protection"];
productType["Decal"] = ["Contour Cut", "UV Protection"];
productType["Yard Sign"] = ["Step Stakes", "UV Protection", "Double Sided", "Rounded Corners", "Contour Cut"];
productType["Digital Print"] = ["Grommets", "UV Protection", "Gloss Finish", "Matte Finish"];
productType["Business Signs"] = ["Double Sided", "Drilled Holes", "Rounded Corners", "Reflective"];
Dan Lowe
  • 51,713
  • 20
  • 123
  • 112
Charles L.
  • 1,844
  • 2
  • 34
  • 56
  • Officially Bootstrap 3 does not support tertiary menus. There are some js plugins out there that will add this ability - but I will forewarn you that they are buggy on some devices (which is why Bootstrap does not officially support this depth of responsive menu). One plugin I have used in the past for this is "bootstrap submenu": http://vsn4ik.github.io/bootstrap-submenu/ It works OK in most testing. – Korgrue Jan 07 '16 at 23:23
  • http://stackoverflow.com/questions/5686735/populate-one-dropdown-based-on-selection-in-another You may find your answer here – MONTS_MIND_Hacker Jan 08 '16 at 03:23

0 Answers0