I want to prompt a user if he wants to do the operation (delete) - say "yes" or "no" with an alert box and if yes then run the delete script or if no then do nothing
I dont know javascript much hence if anyone could get the right script for php with javascript
I want a delete link/button to show an alert while clicking and asked the user to proceed or not, and run the script according to that
Im not sure you can change the button text but the basic window is:
document.getElementById('myDeleteButton').onclick = function(){
return confirm('Are you sure you want to delete?');
};
Here's a link that the browser will only go to if the user confirms:
<a onclick="javascript:return confirm('Are you sure you wish to delete? This action cannot be undone.')" href="DELETE-SCRIPT-URL">Delete</a>
Of course, this will only work if the person has JavaScript enabled, if they don't then it will just be a normal link. The far more complex alternative that would work for people without JavaScript would be to have the link lead the person to a confirmation page, which will then bring them to the actual delete page. I wouldn't advise that, though, since its fairly bad design and requires the user to go through an extra page.