Skip to content Skip to sidebar Skip to footer

Jquery Confirm Delete With Onclick Issue

This is my confirm alert box script: $(document).ready(function(){ $('.confirm').click(function(){ var answer = confirm('Are you sure you want to delete this item?');

Solution 1:

$(document).ready(function(){
    $('.confirm').click(function(){
        if (confirm("Are you sure you want to delete this item?")){
            // your deletion code...returntrue;
        }
        returnfalse;
    });
});

Solution 2:

I used the same functionality for one of my webistes, where I was making the facebook type conversation system, I am sending the code example from it, please get an idea from my code, (sorry, don't have time to set your parameters in the code, so am sending the original code used in my project).

The javascript function:

<scriptlanguage="javascript">functionConfirmDelete(id)
{
    var result = confirm("Are you sure you want to Delete this Conversation ?");
    if (result==true)
    {
        window.location = "index.php?page=inbox&delete_conversation="+id;
    }
}
</script>

HTML, where the title of the conversation is displayed, and an X button is displayed, by clicking on that X button the conversation will be deleted after the confirmation.

<h2><ahref='javascript:ConfirmDelete(<?phpecho$conversation['id']; ?>);'>[x]</a><ahref="index.php?page=view_conversation&amp;conversation_id=<?phpecho$conversation['id']; ?>"><?phpecho$conversation['subject']; ?></a></h2>

Solution 3:

Try this One Friend

   $(document).ready(function () {
      $('#Delete').click(function () {

              var r = confirm("Are you sure want to delete. ");
              if (r == true) {
                  returntrue;
              }
              else {
                  returnfalse;
              }
          }); 
   });

Solution 4:

It would be better to use an anchor in this case:

<aclass="button-content confirm"href="delet-project.php?id=[project]">click me</a>

And then a similar kind of click handler:

jQuery(function($) {
    $('.confirm').click(function(e) {
        if (!confirm("Are you sure you want to delete this item?")) {
            e.preventDefault();
        }
    });
});

Post a Comment for "Jquery Confirm Delete With Onclick Issue"