0

In a php page, I want to make a remove button to delete data in my database. This button would be able to show a pop up box to ask 'yes' or 'no' before you confirm to delete.

"<input type=submit value=Remove onclick='confirm(\"Are you sure to remove Title " . $row['AlbumName'] . " ?\");'>"

This code just can call the pop up box but it can't check the user either click 'yes' or 'no'.

I have tried to echo script with confirm function remove() in , but the function is not work when I set onclick=remove() .

asked Dec 8, 2013 at 7:49

2 Answers 2

1

Try this

<input type=submit value=Remove onclick='confirmDelete(<?=$row['AlbumName']?>);'>
function confirmDelete(AlbumName)
{
var agree=confirm("Are you sure to remove Title "+AlbumName+"?");
if (agree)
 return true ;
else
 return false ;
}
answered Dec 8, 2013 at 7:55
Sign up to request clarification or add additional context in comments.

Comments

0
function doublecheckDelete() {
 if (confirm("really delete") == true) {
 document.deleteform.submit();
 } else {
 alert ("ok, not deleting.");
 }
}
<form name="deleteform" action="delete.php">
... whatever else you need ...
<input type=button onClick="doublecheckDelete()">
</form>
answered Dec 8, 2013 at 7:56

Comments

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.