Search code examples
jquerybuttonconfirm

How to add to a button "jQuery confirm" for confirmation to work


Using the module but after clicking "yes" nothing is sent. Explain, please.

 <form class="zaeb" action="" method="post" id="kek">
                    <input type="hidden" name="type" value="<?php echo $plan->id; ?>">
                    <button id="b12<?php echo $plan->id; ?>" type="submit" class="example2 btn btn-primary btn-lg btn-block" name="buy"><b>CLICK HERE TO PURCHASE</b></button>

jQuery:

                        $('button.example2').confirm({
title: 'Confirm!',
content: 'Simple confirm!',
buttons: {
    confirm: function () {
        $.alert('Confirmed!');
    },
    cancel: function () {
        $.alert('Canceled!');
    },
    somethingElse: {
        text: 'Something else',
        btnClass: 'btn-blue',
        keys: ['enter', 'shift'],
        action: function(){
            $.alert('Something else?');
        }
    }
}
});

I would like to make a beautiful shape.


Solution

  • The confirm function only alerts a confirmed message, you should change

    confirm: function () {
            $.alert('Confirmed!');
        },
    

    to

    confirm: function () {
                document.getElementById("kek").submit();
                $.alert('Confirmed!'); // may need to remove this
                
            },