Shyam K Shyam K - 2 years ago 85
Javascript Question

How to show a confirm message before delete?

I want to get a confirm message on clicking delete (this maybe a button or an image). If the user selects '

' then delete is done, else if '
' is clicked nothing happens.

I tried echoing this when the button was clicked, but echoing stuff makes my input boxes and text boxes lose their styles and design.

Ved Ved
Answer Source

Write this in onclick event of the button:

var result = confirm("Want to delete?");
if (result) {
    //Logic to delete the item
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download