1,批量操作之批量删除(增删改)
<script type="text/javascript">
function seltAll(){
var chckBoxSign = document.getElementById("ckb"); //ckb 全选/反选的选择框id
var chckBox = document.getElementsByName("chckBox"); //所有的选择框其那么都是chckBox
var num = chckBox.length;
if(chckBoxSign.checked){
for(var index =0 ; index<num ; index++){
chckBox[index].checked = true;
}
}else{
for(var index =0 ; index<num ; index++){
chckBox[index].checked = false;
}
}
}
function deleSeltedRecords(){
var chckBox = document.getElementsByName("chckBox");
var num = chckBox.length;
var ids = "";
for(var index =0 ; index<num ; index++){
if(chckBox[index].checked){
ids += chckBox[index].value + ",";
}
}
if(ids!=""){
if(window.confirm("确定删除所选记录?")){
$.ajax( {
type : "post",
url : '../g3/history-no!batchDelete.action?ids=' + ids, //要自行删除的action
dataType : 'json',
success : function(data) {
alert("删除成功");
window.location.href = "channel-no.action" ;
},
error : function(data) {
alert("系统错误,删除失败");
}
});
}
}else{
alert("请选择要删除的记录");
}
}
</script>
2,批量操作之弹出框
<a class="" id="" onclick="show_ad()" style="">设置词</a>
<pre name="code" class="javascript">function show_ad() {
var aaa = "";
jQuery("#tbl_type2 tr").each(function() {
var text = $(this).children("td:first").find("input[type=checkbox]:checked");
if (text.val() != undefined) {
aaa = text.val() + "," + aaa;
}
});
if (aaa != null && aaa != "") {
alert(aaa);
jQuery("#addiv1").css({
display: "block"
});
jQuery("#addiv2").css("display", "block");
} else {
alert("请选择对象");
return false;
}
}<pre name="code" class="html"><td class="td-check"> <input type="checkbox" name="ids" id="selectWare_<s:property value=" id "/>"value="<s:property value=" id "/>"/> </td>
全选的js代码
<pre name="code" class="javascript">//全选、反选
$("#top_selectAll").click(function() {
$('input[type=checkbox]').attr("checked", $(this).attr("checked") ? true: false);
});弹出框代码
<div id="addiv1">
</div>
<div id="addiv2" style="display:none; margin: 0px auto;top: 30%" class="pop pop_v1">
<h4>
<span class="winTitle">
批量设置
</span>
<a id="closead" class="btn_cel">
关闭
</a>
</h4>
<div style=" margin-top: 20px; padding-left: 50px;">
<label>
<font style="font-size: 13px; color: black;">
词:
</font>
</label>
<div>
<s:textarea name="adindroduce" rows="10" style="width: 90%; margin-top: 5px; overflow:scroll; overflow-x:hidden; resize: none;">
</s:textarea>
<br>
<div style="height:10px; ">
</div>
</div>
<br/>
<br/>
<input type="button" id="savecatalog" class="btn-newsearch btn_reelect2"
value="保 存" style="width:72px; font-
size: 12px; padding:0px;" onclick="setad();">
<input type="button" id="quxiao" class="btn-newsearch btn_reelect2" value="取 消"
style="width:72px; font-size: 12px; padding:0px;">
</div>
</div>保存和取消的js代码function setad(){<span style="white-space:pre"> </span> $("#pform").attr("action","<%=basePath%>/manage/product!updateAd.action"); $("#pform").submit(); <span style="white-space:pre"> </span>return false; }
$("#quxiao").click(function() { <span style="white-space:pre"> </span>$("#addiv1").css("display", "none");
<span style="white-space:pre"> </span>$("#addiv2").css("display", "none"); });
$("#closead").click(function(){ <span style="white-space:pre"> </span>$("#addiv1").css("display", "none"); <span style="white-space:pre"> </span>$("#addiv2").css("display", "none");
});原文地址:http://blog.csdn.net/baidu_25310663/article/details/45950689