forum

Home / DeveloperSection / Forums / All bootstrap dropdown show the same item

All bootstrap dropdown show the same item

Anonymous User221704-Oct-2014
i'm using bootstrap dropdown and some jquery code
my problem is when i'm change the value of one dropdown then all dropdown change value automatick

<scriptsrc="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<scriptsrc="https://maxcdn.bootstrapcdn.com/bootstrap/3.2.0/js/bootstrap.min.js"></script>
<linkhref="https://maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap.min.css"rel="stylesheet"/>


here is javascript code:

<script>
    $(function () {
        $(".dropdown-menu li a").click(function () {
            $(".btn:first-child").text($(this).text());
            $(".btn:first-child").val($(this).text());
        });
    });
</script>

here is bootstrap dropdown code:

<divclass="row">
        <divclass="col-md-6">
            <divclass="dropdown">
                <buttonclass="btn btn-default dropdown-toggle"type="button"id="ddlForwardTo"data-toggle="dropdown">
                    Select a Forward To
                    <spanclass="caret"></span>
                </button>
              <ulclass="dropdown-menu"role="menu"aria-labelledby="dropdownMenu1">
                <lirole="presentation"><arole="menuitem"tabindex="-1"href="#">Action</a></li>
                <lirole="presentation"><arole="menuitem"tabindex="-1"href="#">Another action</a></li>
                <lirole="presentation"><arole="menuitem"tabindex="-1"href="#">Something else here</a></li>
              </ul>
            </div>
        </div>
        <divclass="col-md-6">
            <divclass="dropdown">
                <buttonclass="btn btn-default dropdown-toggle"type="button"id="ddlManufacturing"data-toggle="dropdown">
                    Select a Manufacturing contact
                    <spanclass="caret"></span>
                </button>
              <ulclass="dropdown-menu"role="menu"aria-labelledby="dropdownMenu1">
                <lirole="presentation"><arole="menuitem"tabindex="-1"href="#">Action</a></li>
                <lirole="presentation"><arole="menuitem"tabindex="-1"href="#">Another action</a></li>
                <lirole="presentation"><arole="menuitem"tabindex="-1"href="#">Something else here</a></li>
              </ul>
            </div>
        </div>
    </div>

i'm want to not change value of all dropdown onchnage one dropdown value



Updated on 06-Oct-2014
I am a content writter !

Can you answer this question?


Answer

2 Answers

Liked By