i'm currentrly coding in php and when i click a button the message should me Would you like to delete this entry?
This is where I'm currently at
<button onClick="alert('Sure to delete entry?')"><a href="delete.php?delete=<?php echo $row['guestbook_id'];?>">Remove Entry</a></button>
And sure it works. But when I press "x" to close the alert window it still deletes the entry. How can you make a popup window that has the "Cancel" opition?
I would really appreciate the help! :)
The HTML
<a href="delete.php?delete=<?php echo $row['guestbook_id'];?>"
onclick="return areYouSure()">Remove Entry</a>
And the JS
function areYouSure()
{
var con = window.confirm("Are You Sure?");
if(con)
{
return true;
}
else
{
return false;
}
}
You can do this using the following JavaScript code:
if (confirm('Sure to delete entry?') == true) {
//write your code here to delete
}