zoukankan      html  css  js  c++  java
  • 在CheckBox中,仅仅允许选择一项

    作用相当于RadioButonList

    <html xmlns="http://www.w3.org/1999/xhtml">
    <head runat="server">
        <title></title>
        <script type="text/javascript">
            function UncheckOthers(objchkbox) {
                //Get the parent control of checkbox which is the checkbox list
                var objchkList = objchkbox.parentNode.parentNode.parentNode;
                //Get the checkbox controls in checkboxlist
                var chkboxControls = objchkList.getElementsByTagName("input");
                //Loop through each check box controls
                for (var i = 0; i < chkboxControls.length; i++) {
                    //Check the current checkbox is not the one user selected
                    if (chkboxControls[i] != objchkbox && objchkbox.checked) {
                        //Uncheck all other checkboxes
                        chkboxControls[i].checked = false;
                    }
                }
            }
        </script>
    </head>
    <body>
        <form id="form1" runat="server">
            <div>
                <asp:CheckBoxList ID="CheckBoxList1" runat="server">
                    <asp:ListItem Text="FirstValue" Value="1" onclick="UncheckOthers(this);">
                    </asp:ListItem>
                    <asp:ListItem Text="Second Value" Value="2" onclick="UncheckOthers(this);">
                    </asp:ListItem>
                    <asp:ListItem Text="Third Value" Value="3" onclick="UncheckOthers(this);">
                    </asp:ListItem>
                    <asp:ListItem Text="Fourth Value" Value="4" onclick="UncheckOthers(this);">
                    </asp:ListItem>
                    <asp:ListItem Text="Fifth Value" Value="5" onclick="UncheckOthers(this);">
                    </asp:ListItem>
                </asp:CheckBoxList>
            </div>
        </form>
    </body>
    </html>
    
  • 相关阅读:
    Jenkins操作学习 --邮箱配置及测试结果构建
    Jenkins操作学习 --初始化安装
    Jenkins操作学习 -- 配置及使用
    Jenkins登录后空白页
    Linux-(kill,wc,killall,ln,cal,date)
    Linux-(tar,gzip,df,du)
    Linux-(chgrp,chown,chmod)
    Linux-文件和目录属性
    Linux-(which,whereis,locate,find)
    Linux-(touch,cat,nl,more|less,head|tail)
  • 原文地址:https://www.cnblogs.com/songxia/p/4270797.html
Copyright © 2011-2022 走看看