在删除之前确认甜蜜警报

时间:2015-09-01 19:47:08

标签: javascript php jquery sweetalert

  • 我有一个包含公告的数据表,删除按钮工作正常但它删除了公告而没有从脚本获得响应(Sweet Alert)。我希望有人可以提供帮助



<script>
document.getElementById('deleteannun').onclick = function()
{
  swal({
  title: "Are you sure?",
  text: "You will not be able to recover this announcement!",
  type: "warning",
  showCancelButton: true,
  confirmButtonColor: "#DD6B55",
  confirmButtonText: "Yes, delete it!",
  cancelButtonText: "No, cancel please!",
  closeOnConfirm: false,
  closeOnCancel: false
},
function(isConfirm){
  if (isConfirm) {
     return true;
  } else {
    swal("Cancelled", "Your announcement is safe", "error");
    return false;
  }
});
}
</script>
&#13;
//Connection here
$sql = "SELECT annun_ID, annun_title, annun_author, annun_date, annun_details FROM annun order by annun_ID DESC";
$result = $conn->query($sql);
if ($result->num_rows > 0) {
  while($row = $result->fetch_assoc()) {
  echo "<tr><td id=\"titleannun\">". $row["annun_title"]. "</td><td>". $row["annun_author"]. " </td><td>" . $row["annun_date"] . "</td><td>" . $row["annun_details"] ."</td>
 <td>
 <a href='includes/deleteannun.php?title=".$row["annun_title"]."'class=\"btn btn-block btn-danger btn-xs\" ><i class=\"fa fa-trash\" id=\"deleteannun\"></i></a>";
  }
} else {
}
&#13;
&#13;
&#13;

0 个答案:

没有答案