批量删除两种方法总结!

一、首先贴全选代码!
<input οnclick="checkBox();" type="checkbox" name="checkbox"value="1">

<!-- js代码Start,不解释,需要的朋友请自己仔细看 -->
var count=1;
function allSelect(){
for(i=0;i<document.HuiYiZhiLiaoForm.elements.length;i++){
if(document.HuiYiZhiLiaoForm.elements[i].type=="checkbox" ){
document.HuiYiZhiLiaoForm.elements[i].checked=true;
}
}
}
function moveSelect(){
for(i=0;i<document.HuiYiZhiLiaoForm.elements.length;i++){
if(document.HuiYiZhiLiaoForm.elements[i].type=="checkbox"){
document.HuiYiZhiLiaoForm.elements[i].checked=false;
}
}
}
function checkBox(){
if(count%2==0){
count+=1;
moveSelect();
}else{
count+=1;
allSelect();
}
}
<!--Js代码End-->

<tr>
我这里的ws标签就是S 只不过自定义了一些东西罢了
[color=red]<ws:form id="HuiYiZhiLiaoForm"
action="HuiYiZhiLiaoAction!batchDelete.action">[/color]
<table>
!中间是内容iterator什么的
<ws:iterator>
<!--迭代出来的ID-->
[color=red]<input type="checkbox" name="checkid" value="<ws:propertyvalue="#result.ID" />"/>[/color]
</iterator>
</table>
</ws:form></td>
<table>
<tr>
<td>
<font style="cursor: hand" id="Font1">
<a id="batchDelete"
[color=red]href="javascript:window.HuiYiZhiLiaoForm.submit()"[/color] >批量删除</a></font></td>
<tr>
</table>
</tr>


二、是用JQuery
$(document).ready(function() {
$("#batchDelete").click(function() {
var delId = "";
$("input[name=delcheckbox]").each(function() {
delId = delId + $(this).next().val() + ",";
});
var redirectLink = "HuiYiZhiLiaoAction!batchDelete.action?delId=" + delId;
window.location.href = redirectLink;
});
});

[color=red]<ws:iterator>
...中间的省略
<input type="checkbox" name="checkid"value="<ws:propertyvalue="#result.ID" />" />
<input type="hidden" value="<ws:property value="#result.ID" />" />
</ws:iterator>[/color]


[color=red]<font style="cursor: hand" id="Font1">
<a id="batchDelete" href="javascript:window.HuiYiZhiLiaoForm.submit()" >批量删除</a></font></td>[/color]
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值