Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to add delete confirmation message

In HTML, delete_icon is an image class in which if I click it, the email id gets deleted without any confirmation message. I want to add a popup to display when delete_icon is clicked. The popup mentioned above should open and if yes is clicked, the instance should get deleted, otherwise it should return the same. How can I achieve this in jQuery or JavaScript?

like image 355
Monk L Avatar asked Oct 03 '22 21:10

Monk L


2 Answers

You can better use as follows

 <a href="url_to_delete" onclick="return confirm('Are you sure want to dele');">Delete</a>
like image 103
Raghav Rach Avatar answered Oct 12 '22 12:10

Raghav Rach


Hmm. You do this with simple javascript.

<script type="text/javascript">
function deleteImage(x){
    var conf = confirm("Are you sure you want to delete this image?");
    if(conf == true){
        alert("OK... you chose to proceed with deletion of "+x);
    }
}
</script>

Using the default browser confirmation box. And this is the example use of the function.

<input name="myBtn" type="button" onClick="deleteImage('images/pic.jpg')" value="Delete Image">
like image 42
Edwin Lunando Avatar answered Oct 12 '22 10:10

Edwin Lunando