//全选
$("#checkall").click(function(){
$("input[name='id[]']").each(function(){
if (this.checked) {
this.checked = false;
}
else {
this.checked = true;
}
});
})
<td style="text-align:left; padding:19px 0;padding-left:20px;"><input type="checkbox" name="checkall" id="checkall"/>
全选 </td>
//批量删除
function DelSelect(){
var Checkbox=false;
$("input[name='id[]']").each(function(){
if (this.checked==true) {
Checkbox=true;
}
});
if (Checkbox){
var t=confirm("您确认要删除选中的内容吗?");
if (t==false) return false;
$("#listform").submit();
}
else{
alert("请选择您要删除的内容!");
return false;
}
}
//单个删除
function del(id){
if(confirm("您确定要删除吗?")){
$.ajax({
type:'POST',
url:'{:U("del")}',
data:{id:id},
success:function(data){
// alert(data);exit;
if(data==1){
alert('删除成功!');
$("#list"+id).remove();
}else{
alert('删除失败!');
}
}
})
}
}
<tr id="list{$value.id}">
<td style="text-align:left; padding-left:20px;"><input type="checkbox" name="id[]" value="{$value.id}" />
{$value.id}</td>
<td>{$value.name}</td>
<td>{$value.current_time|date='Y-m-d',###}</td>
<td>{$value.nav_name}</td>
<td><div class="button-group"> <a class="button border-main" href="{:U('edit',array('id'=>$value['id']))}"><span class="icon-edit"></span> 修改</a> <a class="button border-red" href="javascript:;" οnclick="return del({$value.id})"><span class="icon-trash-o"></span>删除</a> </div></td>
</tr>
public function delall(){
$new=M('newslead');
$array=I('post.id');
// var_dump($array);die;
$array=join(',',$array);
if($new->where('id in ('.$array.')')->delete()){
$this->success('删除成功',U('index'));
}else{
$this->error('删除失败');
}
}
//批量排序
function sorts(){
var Checkbox=false;
$("input[name='id[]']").each(function(){
if (this.checked==true) {
Checkbox=true;
}
});
if (Checkbox){
$("#listform").submit();
}
else{
alert("请选择要操作的内容!");
return false;
}
}
//批量首页显示
function changeishome(o){
var Checkbox=false;
$("input[name='id[]']").each(function(){
if (this.checked==true) {
Checkbox=true;
}
});
if (Checkbox){
$("#listform").submit();
}
else{
alert("请选择要操作的内容!");
return false;
}
}
//批量推荐
function changeisvouch(o){
var Checkbox=false;
$("input[name='id[]']").each(function(){
if (this.checked==true) {
Checkbox=true;
}
});
if (Checkbox){
$("#listform").submit();
}
else{
alert("请选择要操作的内容!");
return false;
}
}
//批量置顶
function changeistop(o){
var Checkbox=false;
$("input[name='id[]']").each(function(){
if (this.checked==true) {
Checkbox=true;
}
});
if (Checkbox){
$("#listform").submit();
}
else{
alert("请选择要操作的内容!");
return false;
}
}
//批量移动
function changecate(o){
var Checkbox=false;
$("input[name='id[]']").each(function(){
if (this.checked==true) {
Checkbox=true;
}
});
if (Checkbox){
$("#listform").submit();
}
else{
alert("请选择要操作的内容!");
return false;
}
}
//批量复制
function changecopy(o){
var Checkbox=false;
$("input[name='id[]']").each(function(){
if (this.checked==true) {
Checkbox=true;
}
});
if (Checkbox){
var i = 0;
$("input[name='id[]']").each(function(){
if (this.checked==true) {
i++;
}
});
if(i>1){
alert("只能选择一条信息!");
$(o).find("option:first").prop("selected","selected");
}else{
$("#listform").submit();
}
}
else{
alert("请选择要复制的内容!");
$(o).find("option:first").prop("selected","selected");
return false;
}
}