<table border="1">
<tr>
#遍历出数据
<?php foreach($data as $k=>$v) {?>
<td><input type="checkbox" value="<?php echo $id?> "></td>
<td><input type="checkbox" value="<?php echo $id?> "></td>
<td><input type="checkbox" value="<?php echo $id?> "></td>
<td><input type="checkbox" value="<?php echo $id?> "></td>
<td><input type="checkbox" value="<?php echo $id?> "></td>
<td><a href="javascript:void(0)" onclick="del(this,<?php echo $id?> )">删除</a></td>
</tr>
<?php }?>
<button onclick="all_select( true )">全选</button>
<button onclick="un_select( )">反选</button>
<button onclick="all_select( false )">全不选</button>
<button onclick="all_del( )">批量删除</button>
<script>
function all_select(bool)
{
var box=document.getElementByTagName('input');
for( var i=0;i<box.length;i++)
{
box[i].checked==bool;
}
}
function un_select()
{
var box=document.GetElementByTagName('input');
for(var i=0;i<box.length;i++)
{
if(box[i].checked==true)
else{
box[i].checked==false;
}else{
box[i].checked=true;
}
}
}
function del(th,id)
{
var is=confirm("确认删除吗?");
if(is==true)
{
location.href="del.php?id="+id
}
}
function all_del()
{
if(confirm("您确认删除吗"))
{
var checkbox=document.getElementByTagName("input");
var ids=' ';
for(var i=0;i<checkbox.length;i++)
{
if(checked[i].checked)
{
ids+=checked[i].value+','
}
}
location.href="del.php?id="+ids
}
}
</script>