Search code examples
phpjavascriptconfirm

php javascript confirm box for delete


The below code is in PHP

echo "<input type='submit' name='delete' value='$t2[0]' class='delete_button' onclick='return confirm('Please Confirm Delete');'>"

I am trying to create a delete button, when a user clicks on delete button , it should ask confirmation. but in this case, its not working.

is there any best way to delete with confirmation in php with/ or javascript and no ajax


Solution

  • Your quotes are breaking themselves here;

    onclick='return confirm('Please Confirm Delete');'>
    

    Instead use;

    onclick="return confirm('Please Confirm Delete');">