/*删除信息*/
$(function(){
$("#plsc").click(function(){ var idlist=""; var idCount=0; $(":checkbox[checked]").each(function(){ idlist = idlist+$(this).val()+','; idCount++; }); if(idCount==0){ alert("请选择删除对象!"); return ; } $(":checkbox[checked]").each(function(){ $("tr[id="+$(this).val()+"]").remove(); }); $.ajax({ type: "POST", url: "operate/deleteConsume!deleteConsume.action", data:"ids="+idlist, dataType:"json", async: false, success: function(data){ } }); })})
页面代码
<sj:div id="bottom"> <div id="bottom_01"> <img src="<c:url value="/images/rt_name.jpg"/>"/> </div> <div id="bottom_02"> <table width="100%" border="0" cellpadding="0" cellspacing="0"> <tr id="tr_content"> <th width="5%" height="40">ID</th> <th width="15%" height="40">日期</th> <th width="15%" height="40">分类</th> <th width="15%" height="40">金额</th> <th width="15%" height="40">账户</th> <th width="30%" height="40">说明</th> <th width="10%" height="40">操作</th> </tr> <s:if test="listConsume.isEmpty()"> <tr> <td class="a" colspan="5" width="100%" height="100%" align="center"> <img src="<c:url value="/images/nodata.png"/>"/> </td> </tr> </s:if> <s:else> <tr class="table_index"></tr> <s:iterator value="listConsume" id="ss" status="status"> <tr id="<s:property value="#ss.cid"/>" οnmοuseοver="changeBG(this)" οnmοuseοut="changeBG1(this)"> <td width="5%" height="40" align="center"><s:checkbox id="ids" name="ids" value="false" fieldValue="%{#ss.cid}"/> <s:property value="#status.count"/></td> <td width="15%" height="40" align="center"><s:property value="#ss.cdate"/></td> <td width="15%" height="40" align="center"><s:property value="#ss.cname"/></td> <td width="15%" height="40" align="center"><s:property value="#ss.cmoney"/></td> <td width="15%" height="40" align="center"><s:property value="#ss.atype"/></td> <td width="30%" height="40" align="center"><s:property value="#ss.cinstruction"/></td> <td width="10%" height="40" align="center"> <s:url var="url" action=""> <s:param name="" value=""/> </s:url> <s:a οnclick="javascript:return confirm('是否删除?,删除后将不可恢复');" href="%{url}"><img alt="删除" src="<c:url value="/images/del.gif"/>"/></s:a> </td> </tr> </s:iterator> <tr> <td></td> <td> <input type="button" id="checkboxAll" value="全选"/> <input type="button" id="checkboxNo" value="全不选"/> </td> <td> <input type="button" id="checkboxRev" value="反选"/> <input type="button" id="plsc" οnclick="javascript:return confirm('是否删除?,删除后将不可恢复');" value="批量删除"/> </td> <td></td> </tr> </s:else> </table> </div> </sj:div>action 代码
public String deleteConsume()throws Exception{
//批量删除支出信息 String id[] = ids.split("\\,");for(int i=0;i<id.length;i++){
this.iConsumeDao.delete(id[i]); } return SUCCESS; }struts.xml代码
<action name="deleteConsume" class="operateAction"> <result name="success" type="json"> </result> </action>