<删除>按钮:
<a class="btn btn-danger btn-xs" id="del_btn" disabled="disabled" onclick="return confirm('确定要删除?');" href="./category_del.php"><i class="fa fa-times"></i>删除</a>
checkbox :
<input data-id="<?php echo $c['id'];?>" class="checkbox-slider colored-blue btn-xs" type="checkbox">
js:
<script>
$(function(){
var tbodyCheckbox = $('tbody input');
var delBtn = $("#del_btn");
var allCheckedIds = [];
tbodyCheckbox.on('change',function () {
//delBtn.removeAttr('disabled');
var id = $(this).data('id');
if ($(this).prop('checked')){
allCheckedIds.push(id);
}else
{
allCheckedIds.splice(allCheckedIds.indexOf(),1)
}
allCheckedIds.length ? delBtn.removeAttr('disabled'):delBtn.attr("disabled",'disabled');
delBtn.prop('search','?id='+allCheckedIds);
});
});
</script>
php:
if (empty($_GET['id']))
{
exit('缺少必要参数');
}
$id = $_GET['id'];
//判断id是否是数值
$affected_rows = sql_excute("delete from ft_category WHERE id in ({$id});");
if($affected_rows>0)
{
header('Location:./category_list.php');
}
else
{
exit('数据不存在!');
}