使用javascript启用vb.net checkboxlist时出现问题



在页面加载时,im禁用一个复选框列表,当用户选择一个单选按钮时,它会调用一个java函数来启用整个复选框列表。我尝试了很多方法来启用复选框列表,但都没有成功。我是不是错过了什么?

<td><asp:radiobutton id="radApprove" runat="server" Groupname="radDisp" Text="Approved" onclick="radioButtons(this)"/>
</td>
<td>Method of Validation:
<asp:checkboxlist id="chkMethodUsed" runat="server" 
style="margin-top: 0px">
<asp:ListItem>AD</asp:ListItem>
<asp:ListItem>ESM</asp:ListItem>
<asp:ListItem>EWT</asp:ListItem>
<asp:ListItem>SB</asp:ListItem>
<asp:ListItem>WorkOrder</asp:ListItem>
</asp:checkboxlist>

下面的这些java语句都不会启用复选框列表

if (pobjButton.id == "radApprove") 
{
var a = document.getElementById('<%=chkMethodUsed.ClientID%>')
a.removeAttribute('disabled');
a.attributes.disabled = false
a.disabled = false
a.parentNode.removeAttribute('disabled');
document.getElementsByName('chkMethodUsed').disabled = false;
document.getElementById('chkMethodUsed').disabled = false;
document.getElementById('chkMethodUsed').removeAttribute("disabled");
}

从这里开始:

.Aspx:

<form id="form1" runat="server">
<div>
<asp:RadioButton ID="radDisable" runat="server" GroupName="radDisp" Text="Disable" onclick="radioButtons(this)" />
<asp:RadioButton ID="radEnable" runat="server" GroupName="radDisp" Text="Enable" onclick="radioButtons(this)" />
<asp:CheckBoxList ID="chkMethodUsed" runat="server"
Style="margin-top: 0px">
<asp:ListItem>AD</asp:ListItem>
<asp:ListItem>ESM</asp:ListItem>
<asp:ListItem>EWT</asp:ListItem>
<asp:ListItem>SB</asp:ListItem>
<asp:ListItem>WorkOrder</asp:ListItem>
</asp:CheckBoxList>
</div>
</form>

.js:

function radioButtons(pobjButton) {
var parentChecks = document.getElementById('chkMethodUsed');
var checks = parentChecks.querySelectorAll("input[type='checkbox']");
try {
switch (pobjButton.id) {
case "radDisable":
for (var i = 0; i < checks.length; i++) {
checks[i].setAttribute("disabled", "disabled");
}
break;
case "radEnable":
for (var i = 0; i < checks.length; i++) {
checks[i].removeAttribute("disabled");
}
break;
}
}
catch (e) {
console.log(e.toString());
}
}

最新更新