zoukankan      html  css  js  c++  java
  • 删除多条商品

    <script type="text/javascript">
            $(function(){
                /** 获取上一次选中的部门数据 */
                var boxs  = $("input[type='checkbox'][id^='box_']");
                
               /** 给全选按钮绑定点击事件  */
                $("#checkAll").click(function(){
                    // this是checkAll  this.checked是true
                    // 所有数据行的选中状态与全选的状态一致
                    boxs.attr("checked",this.checked);
                })
                
               /** 给数据行绑定鼠标覆盖以及鼠标移开事件  */
                $("tr[id^='data_']").hover(function(){
                    $(this).css("backgroundColor","#eeccff");
                },function(){
                    $(this).css("backgroundColor","#ffffff");
                })
                
                
                /** 删除员工绑定点击事件 */
                $("#delete").click(function(){
                    /** 获取到用户选中的复选框  */
                    var checkedBoxs = boxs.filter(":checked");
                    if(checkedBoxs.length < 1){
                        $.ligerDialog.error("请选择一个需要删除的部门!");
                    }else{
                        /** 得到用户选中的所有的需要删除的ids */
                        var ids = checkedBoxs.map(function(){
                            return this.value;
                        })
                        
                        $.ligerDialog.confirm("确认要删除吗?","删除部门",function(r){
                            if(r){
                                // alert("删除:"+ids.get());
                                // 发送请求
                                //window.location = "${pageContext.request.contextPath}/dept/removeDept?ids=" + ids.get();
                               $.get("${pageContext.request.contextPath}/dept/removeDept.do?ids="+ids.get(),
                                   function (data) {
                                           if (data == "OK"){
                                               alert("部门删除成功!");
                                               window.location.href = "${pageContext.request.contextPath}/dept/findDept.do";
                                        } else if (data == "FAIL") {
                                            alert("部门删除失败!");
                                            window.location.reload();
                                        } else if(data == "ERROR"){
                                            alert("该部门存在员工,不能删除!");
                                            window.location.reload();
                                        }else {
                                            alert("内部服务器异常!");
                                            window.location.reload();
                                        }
                               });
    
    
                            }
                        });
                    }
                })
            })
        </script>
     <tr valign="top">
            <td height="20">
              <table width="100%" border="1" cellpadding="5" cellspacing="0" style="border:#c2c6cc 1px solid; border-collapse:collapse;">
                <tr class="main_trbg_tit" align="center">
                  <td><input type="checkbox" name="checkAll" id="checkAll"></td>
                  <td>部门名称</td>
                  <td>详细信息</td>
                  <td align="center">操作</td>
                </tr>
                <c:forEach items="${requestScope.depts}" var="dept" varStatus="stat">
                    <tr id="data_${stat.index}" align="center" class="main_trbg" onMouseOver="move(this);" onMouseOut="out(this);">
                        <td><input type="checkbox" id="box_${stat.index}" value="${dept.id}"></td>
                         <td>${dept.name }</td>
                          <td>${dept.remark }</td>
                         <td align="center" width="40px;">
                         <a href="${pageContext.request.contextPath}/dept/findDeptById.do?id=${dept.id}">
                                <img title="修改" src="${pageContext.request.contextPath}/images/update.gif"/>
                        </a>
                          </td>
                    </tr>
                </c:forEach>
              </table>
            </td>
          </tr>
     @RequestMapping("/removeDept.do")
        @ResponseBody
        public String removeDept(Integer[] ids){
            //System.out.println(ids[0]);
            try {
                int rows = deptService.removeDept(ids);
                if (rows == ids.length){
                    return "OK";
                }else {
                    return "FAIL";
                }
            }catch (DataIntegrityViolationException e){
                return "ERROR";
            }
        }
      <delete id="deleteEmployee">
            delete from employee_inf where id in
            <foreach collection="ids" item="id" open="(" close=")" separator=",">
                #{id}
            </foreach>
        </delete>
  • 相关阅读:
    Sona && Little Elephant and Array && Little Elephant and Array && D-query && Powerful array && Fast Queries (莫队)
    P1494 [国家集训队]小Z的袜子(luogu)
    【题解】洛谷P1311 [NOIP2011TG] 选择客栈(递推)
    【题解】洛谷P2296 [NOIP2014TG] 寻找道路(SPFA+DFS)
    【题解】洛谷P2661 [NOIP2015TG] 信息传递
    【题解】洛谷P1065 [NOIP2006TG] 作业调度方案(模拟+阅读理解)
    【题解】洛谷P1032 [NOIP2002TG]字串变换(BFS+字符串)
    [BZOJ2127]happiness-[网络流-最小割]
    [BZOJ3218]a + b Problem-[主席树+网络流-最小割]
    BZOJ4049][CERC2014]Mountainous landscape-[线段树+凸包+二分]
  • 原文地址:https://www.cnblogs.com/liuna369-4369/p/11040024.html
Copyright © 2011-2022 走看看