How can I set alert confirmation window when delete button pressed

Muhammad Awais

I want to add confirmation window when someone click on delete button, I'm using this code

$(document).ready(function() {
    $("#btn_delete").click(function() {
        $("#delete_id").val("y");
        $("#myform").submit();
    });
});

It just delete data without confirmation/alert message, anyone help me to sort out my query.

Thanks

Arun P Johny

You can use the confirm dialog to have a confirmation dialog displayed

$(document).ready(function () {
    $("#btn_delete").click(function (e) {
        e.preventDefault();
        if (confirm('Do you want to delete')) {
            $("#delete_id").val("y");
            $("#myform").submit();
        }
    });
});

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

How can I make a JavaFX confirmation alert box wait till OK is pressed but perform other actions when other buttons are pressed

How can i delete certain elements when button is pressed in android

How can I redirect to another template when the submit button is pressed in Alert Ionic Framework?

How can I simulate a different button pressed when a button is pressed?

How can I deselect a button when other consecutive button is pressed?

How can I set a NSTimer based on what button is pressed?

How can I change icon of image view when a button is pressed?

How can I execute the function when button in wxYES_NO is pressed?

How can I make a new scene fade in when a button is pressed?

how can I clear data when device back button is pressed?

(tornado)how can I pass argument to server when a button is pressed?

How can I call a function when the navigation back button is pressed?

How can I deselect radio buttons when back button is pressed?

How can I flip an entire Tableview when a button is pressed in swift?

how can i show calculating alert when clicking button

How to stop alert box to display when back button is pressed in PHP?

How to open a window and close another window when a button is pressed with javascript?

How to delete entire hyperlink when backspace or delete button is pressed?

How can I show the visual effect of a pressed button when I press another button?

How to delete the items from confirmation popup when we click on button

How can I open the modal when I click the delete button?

Detecting button pressed when there are multiple alert views

How can I trigger the Jquery .on() function when the mouse button is pressed, instead of when it is released.

Android - how can i know where was the focus when i pressed a button?

How Can I change the button background when is pressed and keep changing after I stop pressing it?

Can I detect whether a key is pressed when a window gains focus?

How to enable confirmation alert when using 'rm' command to delete files / folders?

How do I call a button function when the button is not being pressed

Can't set confirmationHandler on a connection with confirmation-window-size < 0 error when deployBridge with DEFAULT_CONFIRMATION_WINDOW_SIZE(-1)