【发布时间】:2014-02-14 02:56:20
【问题描述】:
我正在尝试使用此代码禁用我的 aspcheckbox 列表中的其他选项(不是复选框,这是 asp.net checkboxlist 控件)...
这里是jquery
$(document).ready(function () {
$('#<%=lstExposureValue.ClientID%> input:checkbox').click(function () {
var currentIdone = 'Unknown';
var checked = false;
$('#<%=lstExposureValue.ClientID%> input:checkbox').each(function () {
var currentId = $(this).next().html();
if (currentId == currentIdone) {
if (checked) {
$(this).prop('enabled', true);
$("#<%=lstExposureValue.ClientID%> input:checkbox:not(:checked)").prop("enabled", true);
checked = false;
return;
}
else {
$("#<%=lstExposureValue.ClientID%> input:checkbox:not(:checked)").prop("disabled", true);
$("#<%=lstExposureValue.ClientID%> input:checkbox:not(:checked)").prop("checked", false);
checked = true;
}
}
});
});
});
这里是asp.net
<h3>
One</h3>
<asp:CheckBoxList ID="lstExposureValue" runat="server">
<asp:ListItem>Short-term exposure</asp:ListItem>
<asp:ListItem>Medium-term exposure</asp:ListItem>
<asp:ListItem>Unknown</asp:ListItem>
</asp:CheckBoxList>
so when unknown is selected the other 3 options has to be unselected and disabled. 如果未选中未知,则应启用所有选项。
现在无论我选择哪个选项,它都会禁用其他选项,当我取消选中相同的选项时,它会禁用所有选项,任何人都可以帮忙.....
【问题讨论】:
标签: javascript jquery asp.net checkboxlist