首页 > 代码库 > Js全选,插入实现

Js全选,插入实现

  //全选        function CheckAll() {            ids.splice(0, 1000000);            var flag = $("#All_Check").attr("checked");            $(".orderCheck").each(function () {                    if (typeof (flag) == ‘undefined‘)                        flag = false;                    //$(":input[type=checkbox]").attr("checked", flag);                    $(this).children().attr("checked", flag);                    if ($(this).children().attr("checked")) {                        ids.push($(this).attr("SupplierId"));                    } else {                        for (var i in ids) {                            if ($(this).attr("SupplierId") == ids[i]) {                                ids.splice(i, 1);                                break;                            }                        }                    }                }            );            $("#hfids").val(ids);        }        //插入订单号        function InsertOrderCoder(obj) {            if (obj.attr("checked")) {                ids.push(obj.parent().attr("SupplierId"));            }            else {                for (var i in ids) {                    if (obj.parent().attr("SupplierId") == ids[i]) {                        ids.splice(i, 1);                        break;                    }                }            }            $("#hfids").val(ids);        }        //点击搜索加载所有勾选的供应商        function ConfirmSelectedId()        {            ids.splice(0, 1000000);            $(".orderCheck").each(function () {                if ($(this).children().attr("checked")) {                    ids.push($(this).attr("SupplierId"));                }             }            );            $("#hfids").val(ids);        }  <td style="text-align:right;">                 <asp:Button ID="btSearch" Text="搜索" runat="server" style="height: 25px; width: 60px;" OnClick="btSearch_Click" OnClientClick="ConfirmSelectedId();"/>            </td> <th width="4%">                 <input type="checkbox" id="All_Check" onclick="CheckAll();" /></th> <td align="center">                         <%--<input type="checkbox" class="orderCheck" value=http://www.mamicode.com/‘<%# Eval("SupplierId")%>‘ name="<%# Eval("ProductBaseId")%>" onclick="InsertOrderCoder($(this));" />--%>                          <asp:CheckBox runat="server" CssClass="orderCheck"  SupplierId=‘<%# Eval("SupplierId")%>‘ onclick="InsertOrderCoder($(this));"/>                                                   </td>

 

Js全选,插入实现