• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 2258
  • Last Modified:

Alert before delete

Hey guys, I have this code to delete some data from my db:

<a href="?acao=delete&id=<?php echo $row['id'] ?>">Delete</a>

How can I add a javascript alert that ask the user to confirm or cancel before delete the data?!
0
fackz
Asked:
fackz
  • 2
1 Solution
 
Loganathan NatarajanLAMP DeveloperCommented:
simple way,


<a href="?acao=delete&id=<?php echo $row['id'] ?>" onclick="return confirm('Do you want to really delete?');">Delete</a>

Open in new window

0
 
erikTsomikSystem Architect, CF programmer Commented:
0
 
Loganathan NatarajanLAMP DeveloperCommented:

<html>
<head>
<script language="JavaScript">
function confirmSubmit() {
var agree=confirm("Are you sure you wish to continue?");
if (agree)
     return true;
else
     return false;
}
</script>
</head>
 
<body>
<a href="?acao=delete&id=<?php echo $row['id'] ?>" onclick="return confirmSubmit()" >Delete </a>
</body>
</html>

Open in new window

0
 
fackzAuthor Commented:
exactly what I need...thank you very much!
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now