现在的位置: 首页 > 综合 > 正文

利用javascript防止CheckBoxList多选

2012年10月08日 ⁄ 综合 ⁄ 共 740字 ⁄ 字号 评论关闭
 <asp:ListItem onclick="CheckBoxList_Click(this)"  Value="1">同意</asp:ListItem>
                <asp:ListItem onclick="CheckBoxList_Click(this)"  Value="0">不同意</asp:ListItem>
                <asp:ListItem onclick="CheckBoxList_Click(this)"  Value="3">其它</asp:ListItem>

   
function CheckBoxList_Click(sender) 
    {
        
var container = sender.parentNode;        
        
if(container.tagName.toUpperCase() == "span") { 
            container 
= container.parentNode.parentNode;
        }        
        
var chkList = container.getElementsByTagName("input");
        
var senderState = sender.checked;
        
for(var i=0; i<chkList.length;i++) {
            chkList[i].checked 
= false;
        }     
        sender.checked 
= senderState;          
    }

抱歉!评论已关闭.