-2

I have a

           <a href="#" onclick="ConfirmDelete()" class="btn btn-danger my-1 mx-1"> delete </a>

           function ConfirmDelete() {
confirm("delete user");
    }

so the problem is that hello there is a problem when I press cancel it still deletes the user info ( it executes the same order no matter you press cancel or ok )

holyblast
  • 101
  • 6

1 Answers1

2

confirm returns true/false depending on user input. So if it returns true, then continue. If it returns false, do not do anything.

function ConfirmDelete() {
    if (confirm("delete user")){
      //do something
    }
}
Justice Erolin
  • 2,869
  • 20
  • 19