怎样用JS取消 checkboxlist 的不可用状态?
在后台设置了 checkboxlist.Enabled=false;
在前台用如下代码不能取消不可用状态:
var checkelems=document.getElementById('<%=CheckBoxTDepart.ClientID%>').getElementsByTagName("input");
for(var i=0;i<checkelems.length;i++)
{
if(checkelems[i].type=="checkbox")
checkelems[i].disabled=false;
}
checkelems[i].disabled=false; 这句有问题吗?
------解决方案--------------------------------------------------------
checkboxlist显示后的HTML,用JS来控制是不是.......
<table id="CheckBoxList1" disabled="disabled" border="0">
<tr>
<td><span disabled="disabled"><input id="CheckBoxList1_0" type="checkbox" name="CheckBoxList1$0" disabled="disabled" /></span></td>
</tr>
</table>
------解决方案--------------------------------------------------------
- HTML code
<html><head runat="server"> <title>无标题页</title> <script language="javascript" type="text/javascript"> function visi() { var checklist = document.getElementById('CheckBoxList1'); checklist.disabled = false; var spans = checklist.getElementsByTagName('span'); var inputchecks = checklist.getElementsByTagName('input'); for(var i = 0 ; i < spans.length ; i++) { spans[i].disabled=false; inputchecks[i].disabled=false; } } </script></head><body> <form id="form1" runat="server"> <div> <asp:CheckBoxList ID="CheckBoxList1" runat="server"> <asp:ListItem>1</asp:ListItem> <asp:ListItem>2</asp:ListItem> <asp:ListItem>3</asp:ListItem> </asp:CheckBoxList> <button onclick="visi();">onclick</button> </div> </form></body></html>