博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
JQUERY批量操作
阅读量:6330 次
发布时间:2019-06-22

本文共 1425 字,大约阅读时间需要 4 分钟。

主要针对页面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();
            });

转载于:https://www.cnblogs.com/syfblog/archive/2012/12/13/2816511.html

你可能感兴趣的文章
论windows系统的安全性(中篇)
查看>>
jQuery 菜单切换
查看>>
DIV浮动层绝对居中定位用CSS怎么写
查看>>
CC攻击
查看>>
ASP.NET 简单的柱形图实现(附带示例)
查看>>
Hugepages你用了吗?--原理概念篇
查看>>
Mac idea 快捷键
查看>>
Linux服务器部署系列之二—MySQL篇
查看>>
原创企业级控件库之图片浏览控件
查看>>
shell脚本工具之awk命令
查看>>
编译运行实现两个变量值交换的方法
查看>>
每日构造与冒烟测试
查看>>
WindowsPhone7入手,实在的照片
查看>>
iptables实现7层过滤
查看>>
《TCP/IP详解卷1:协议》第6章 ICMP:Internet控制报文协议---读书笔记
查看>>
AS3.0中的显示编程(四)-- DisplayObjectContainer
查看>>
Lock应用之 可中断
查看>>
varnish缓存实现动静分离
查看>>
[jQuery]empty()和remove()的区别
查看>>
WSUS Technology Overview
查看>>