I am working show the drop down values on selection of a check box. But with the below code, all different items that are present in the drop down coming directly.
Somehow the @Html.DropDownListFor is not working inside select tag, can anyone please help me to fix it?
Note: Checkbox toggle working perfectly.
Thank you,
.cshtml
<input type="checkbox" />
<p>check this box to escalate</p>
<select disabled="disabled">
@Html.DropDownListFor(
model => model.EscalationQueue,
new SelectList(Extensions.EscalationQueue, Model.EscalationQueue),
new { @class = "escalation-queue", name = Model.EscalationQueue }
)
</select>
.js file
var dropdownToggle = function () {
$("input:checkbox").change(function () {
if ($("input:checkbox").is(":checked")) {
$("select").removeAttr("disabled");
}
else {
$("select").attr("disabled", "disabled");
}
});
}
$(document).ready(function () {
dropdownToggle();
});
Output:

