I have 2 dropdowns with same id on each select tag , something like this :
dropdown 1:
<select class="form-control" data-val="true" data-val-number="The field Id must be a number. id="Id" name="Id">...</select>
dropdown 2 :
<select class="form-control" id="Id" name="Id"><option value="21">Pre-Production</option>
<option value="18">In Viability Test </option>
</select>
Right now im calling the Ids like this way:
$(document).ready(function () {
$("#Id").change(function () {
... $("#Id").empty(); ...
This is how the both dropdowns are generated in html:
div class="card-body">
<form action="#">
<div class="form-group-feedback form-group-feedback-left"">
@Html.DropDownListFor(model => model.Class1.OfType<Class1>().FirstOrDefault().Id, Model.SelectedListClass1, new { @class = "form-control" })
</div>
</form>
</div>
div class="card-body">
<form action="#">
<div class="form-group-feedback form-group-feedback-left"">
@Html.DropDownListFor(model => model.Class2.OfType<Class2>().FirstOrDefault().Id, Model.SelectedListClass2, new { @class = "form-control" })
</div>
</form>
</div>
The problem is that #Id from first and form other dropdown have same #id (select#Id-form-control).
I would like to know how can i distinct those ids using jquery.