我的看法如下
@Html.DropDownListFor(m => m.Student, (List<SelectListItem>)ViewBag.Students, new { @id = "inputtext", @class = "form-control"})
<div class="form-group">
@Html.LabelFor(m => m.Teacher, new { @class = "control-label col-sm-2" })
<div class="col-sm-10">
@Html.RadioButtonFor(m => m.Teacher, "1")<span>A Transfer</span>
@Html.RadioButtonFor(m => m.Teacher, "2")<span>B</span>
@Html.RadioButtonFor(m => m.Teacher, "3")<span>C</span>
</div>
</div>
我需要一个脚本,该脚本将根据特定的下拉菜单选择启用/禁用单选按钮。如果下拉菜单的值为1,则所有单选按钮都将被禁用。如果下拉列表的值不为1,则启用单选按钮。 我在剃刀视图中感到困惑。请帮助:)
答案 0 :(得分:0)
我已使用此代码根据下拉选择启用/禁用文本框。用您的单选按钮名称替换(“ NO ”),并用1
替换(opts.value == 'Y')Y。function updateTextBox(opts) {
var chks = document.getElementsByName("NO");
if (opts.value == 'Y') {
for (var i = 0; i <= chks.length - 1; i++) {
chks[i].disabled = false;
}
}
else {
for (var i = 0; i <= chks.length - 1; i++) {
chks[i].disabled = true;
chks[i].checked = false;
}
}
}