zoukankan      html  css  js  c++  java
  • JQUERY批量操作

    主要针对页面table表中多项选择所进行的批量审核的操作:

    页面html代码:

    <table>
                            <tr>
                                 <th>
                                    <input type="checkbox" name="ckall" id="ckall" />  //表格中第一行控制是否全选
                                </th>
                                <th>
                                    订单编号
                                </th>
                              
                                <th>
                                    联系人
                                </th>
                                <th>
                                    电话或手机
                                </th>
                                <th>
                                    Email
                                </th>
                                <th>
                                    订购日期
                                </th>
                                <th>
                                    审核状态
                                </th>
                                <th>
                                </th>
                              
                            </tr>
                           
                                foreach (var item in Model.Collection)   //这是我用mvc框架举得一个列子,强类型绑定数据,对数据进行循环遍历
                                {
                                <tr>
                                    <td>
                                        <input type="checkbox" name="ckitem" value="@item.ID"  />  //选择项
                                    </td>
                                    <td>@item.OrderNo
                                    </td>
                                  
                                    <td>@item.LinkMan
                                    </td>
                                    <td>@item.TelOrMobile
                                    </td>
                                    <td>@item.Email
                                    </td>
                                    <td>@item.OrderDate
                                    </td>
                                    <td>
                                    @if(!item.TripStatus)
                                    {
                                        <div style="color:Red">未审核</div>
                                    }
                                   else
                                   {
                                        <div>已审核</div>
                                    }
                                    </td>
                                    <td>
                                   
                                        @Html.ActionLink("审核", "GetStatus", "SuperMarket", new { Id = @item.ID }, null)
                                  
                                    </td>
                                   
                                </tr>
                                }
                          
                        </table>

    页面jquery代码:

     $("#ckall").live('click', function () {
                    var vl = $(this).attr("checked") == "checked";
                    $("input[name='ckitem']").attr("checked", vl);
                });
                $("#shenhe").click(function () {
                    if ($("input[name='ckitem']:checked").length == 0) {

                        alert("请选中数据");
                        return false;
                    } else {
                        var ids = new Array();
                        $("input[name='ckitem']:checked").each(function () {
                            var vl = $(this).val();
                            ids.push(vl);
                        });
                        $.post("/SuperMarket/ShenHe", { ids: ids.toString() })  //要处理的函数
                    .success(function () { alert("批量审核通过!"); window.location.reload(); })
                    .error(function () { alert("处理出错", "提示"); window.location.reload(); });
                    }
                    //window.location.reload();

                });

  • 相关阅读:
    Skim设置豆沙绿背景色的方法
    被咬掉一口的苹果标识的快捷键
    删除 Mac OS X 中“打开方式”里重复或无用的程序列表
    Android开发学习笔记1
    新学到的Eclipse快捷键 2个
    Android开发学习笔记2
    Mac下Eclipse的自动补全设置
    Nsight Eclipse关于CUDA程序语法高亮颜色的调整
    Tecpolt for mac
    转载:Nsight颜色设置
  • 原文地址:https://www.cnblogs.com/syfblog/p/2816511.html
Copyright © 2011-2022 走看看