article

Sunday, November 8, 2015

Jquery Multipele Delete


Jquery Multipele Delete





 
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Jquery 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?")){
    el=$(this)
    $.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" class="delete">delete</a></caption>
<tr>
<td><input type="checkbox" value="1" name="chk[]" class="chk" /></td><td>category a</td>
</tr>
<tr>
<td><input type="checkbox" value="2" name="chk[]" class="chk" /></td><td>category b</td>
</tr>
<tr>
<td><input type="checkbox" value="3" name="chk[]" class="chk" /></td><td>category c</td>
</tr>
<tr>
<td><input type="checkbox" value="4" name="chk[]" class="chk" /></td><td>category d</td>
</tr>
<tr>
<td><input type="checkbox" value="5" name="chk[]" class="chk" /></td><td>category e</td>
</tr>
</table>
</body>
</html>

Related Post