zoukankan      html  css  js  c++  java
  • 复选框、单选框 jquery判断是否选中Demo

    <%@ Page Language="C#" AutoEventWireup="true" CodeBehind="eachcheckbox.aspx.cs" Inherits="WebApplication1.eachcheckbox" %>
    
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head runat="server">
        <title></title>
        <script src="Scripts/jquery-1.4.1.js" type="text/javascript"></script>
        <script type="text/javascript">
    
            $(function () {
                var cnt = 0;
                var sel = '';
                $("#btnclick").click(function () {
                    //debugger;
                    var items = jQuery("input:checked[guid]");
                    items.each(function () {
                        if (jQuery(this).attr("guid")) {
    
                            sel += "," + jQuery(this).attr("guid");
                            cnt += 1;
                        }
                        else {
    
                        }
                    });
    
    
                    if (cnt < 1) {
                        alert('请选择记录!');
                        return false;
                    } else {
                        // if (confirm('确定要删除吗?')) {
                        alert(sel);
                        // }
                    }
                    sel = "";
    
                });//获取选中的是哪一个
    
                $("#chkIsPublic").click(function () { //对单选按钮单击
                    var ss = $('input:radio:checked').val();
                    alert(ss);
                });
            });
    
            //复选框全选
            function aa(obj) {
    
                $(".checkBox>input").attr("checked", $(obj).attr("checked"));
                $(".checkBox").attr("checked", $(obj).attr("checked"));
            }
           
        </script>
    </head>
    <body>
        <form id="form1" runat="server">
        <input type="button" id="btnclick" value="获取选中的是哪一个" />
        
        <div>
            <table>
            <tr>
               <td colspan="3"><input type="checkbox" id="checkAll" onclick="aa(this)" />全选</td>
            </tr>
                <tr>
                    <td>
                        <input type="checkbox" id="chkguid" guid="class1" class="checkBox" />班级1
                    </td>
                    <td>
                        <input type="checkbox" id="Checkbox1" guid="class2" class="checkBox" />班级2
                    </td>
                    <td>
                        <input type="checkbox" id="Checkbox2" guid="class3" class="checkBox" />班级3
                    </td>
                </tr>
            </table>
        </div>
        <div>
            ----------------------------------------------------------------------------------------------
        </div>
        <asp:RadioButtonList ID="chkIsPublic" runat="server" RepeatDirection="Horizontal"
            RepeatLayout="Flow" RepeatColumns="5">
            <asp:ListItem Value="0" Selected="True">租赁</asp:ListItem>
            <asp:ListItem Value="1">购买</asp:ListItem>
            <asp:ListItem Value="2">代理商</asp:ListItem>
        </asp:RadioButtonList>
        </form>
    </body>
    </html>
  • 相关阅读:
    三数之和
    罗马数字与整数
    Oracle 开启或关闭归档
    Oracle RMAN scripts to delete archivelog
    Oracle check TBS usage
    Oracle kill locked sessions
    场景9 深入RAC运行原理
    场景7 Data Guard
    场景4 Data Warehouse Management 数据仓库
    场景5 Performance Management
  • 原文地址:https://www.cnblogs.com/jbps/p/3571507.html
Copyright © 2011-2022 走看看