this tutorial will show you how to delete more than one data with ajax methode using jquery..
first create file, just named it index.php in this file we create a list of category with check box and a link to delete the category.
you can download the sample here
index.php
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Multipele Delete</title>
<script type="text/javascript" src="scripts/jquery.js"></script>
<script type="text/javascript">
$(function(){
$("a.delete").click(function(){
page=$(this).attr("href");
ids=new Array()
a=0;
$("input.chk:checked").each(function(){
ids[a]=$(this).val();
a++;
})
if(confirm("Are you sure want to delete?")){
$.ajax({
url:page,
data:"id="+ids,
type:"GET",
success:function(res)
{
if(res==1)
{
$("input.chk:checked").each(function(){
$(this).parent().parent().remove();
})
}
}
})
}
return false;
})
})
</script>
</head>
<body>
<table>
<caption><a href="delete.php">delete</a></caption>
<tr>
<td><input type="checkbox" value="1" name="chk[]" /></td><td>category a</td>
</tr>
<tr>
<td><input type="checkbox" value="2" name="chk[]" /></td><td>category b</td>
</tr>
<tr>
<td><input type="checkbox" value="3" name="chk[]" /></td><td>category c</td>
</tr>
<tr>
<td><input type="checkbox" value="4" name="chk[]" /></td><td>category d</td>
</tr>
<tr>
<td><input type="checkbox" value="5" name="chk[]" /></td><td>category e</td>
</tr>
</table>
</body>
</html>
the above code contain jquery code to populate the checked value of check box.
ids=new Array()
a=0;
$("input.chk:checked").each(function(){
ids[a]=$(this).val();
a++;
})
after that we sent that value via ajax to php file that run a delete query;
delete.php
// in this file we will run aquery code. to delete the category by getting the unique id. //$id=$_GET['id']. echo 1;
the value of the chk box is not displayed in the delete.php page…
plz help me..