PHP: Show yes/no confirmation dialog

后端 未结 13 2077
爱一瞬间的悲伤
爱一瞬间的悲伤 2021-01-30 18:27

My PHP page has a link to delete one MySQL table datum. I want it to be in such a way that when I click the \'delete\' link a confirmation box should appear and it should ask \

13条回答
  •  小鲜肉
    小鲜肉 (楼主)
    2021-01-30 19:10

    The best way that I found is here.

    HTML CODE

    Delete
    

    ADD THIS TO HEAD SECTION

    $(document).ready(function() {
        $('a[data-confirm]').click(function(ev) {
            var href = $(this).attr('href');
            if (!$('#dataConfirmModal').length) {
                $('body').append('');
            } 
            $('#dataConfirmModal').find('.modal-body').text($(this).attr('data-confirm'));
            $('#dataConfirmOK').attr('href', href);
            $('#dataConfirmModal').modal({show:true});
            return false;
        });
    });
    

    You should add Jquery and Bootstrap for this to work.

提交回复
热议问题