把asp:CheckBoxList 变成单选框

单选框代码

<asp:CheckBoxList runat="server" RepeatDirection="Horizontal" ID="MaintainPeopleCbl" >

                        <asp:ListItem Value="0" Text="是" onclick="checkBoxList_Click(this)"></asp:ListItem>

                        <asp:ListItem Value="0" Text="否" onclick="checkBoxList_Click(this)"></asp:ListItem>

                    </asp:CheckBoxList>

 

javascript 处理事件

 <script type="text/javascript">

        function checkBoxList_Click(sender) {

            

            var container = sender.parentNode;

            if (container.tagName.toUpperCase() == "TD") {

                container = container.parentNode.parentNode;

            }

            var clickList = container.getElementsByTagName("input");

            var senderState = sender.checked;

          

            for (var i = 0; i < clickList.length; i++) {

                clickList[i].checked = false;

            }

            sender.checked = senderState;

        }

    </script>

 

你可能感兴趣的:(checkbox)