全选与删除

来源:互联网 发布:access数据库 绿色版 编辑:程序博客网 时间:2024/05/12 13:14
    <script type="text/javascript">        //function Del(data) {        //    return "<a href='HomeGovernanceList.aspx?Id=" + data["Id"] + "&action=stype' target='_self'>删除</a>";        //}              $(function () {                       // chkAll全选事件            $("#checkAll").bind("click", function () {                $("[name = ckb]:checkbox").attr("checked", this.checked);            });                         //ckb事件            $("[name = ckb]:checkbox").bind("click", function () {                var $chk = $("[name = ckb]:checkbox");                $("#checkAll").attr("checked", $chk.length == $chk.filter(":checked").length);            })        });        function Delete() {            var ids = "";            $("input:checkbox[name='ckb']:checked").each(function (i) {                if (i == 0) {                    ids = $(this).val();                }                else {                    ids += ("," + $(this).val());                }            });            if (ids == "") {                alert("请至少选择一项删除!");                return false;            }            else {                $.ajax({                    url: "GetDelete/HomeGovernanceDel.aspx",                    type: "post",                    async: false,                    data: { "Ids": ids },                    error: function () {                        alert("系统出错");                    },                    success: function (data) {                    }                });                alert("删除成功!");                window.location.reload();            }        }    </script>

0 0