如何在SweetAlert内部使用JSP代码并遵守条件块?

时间:2019-06-21 21:19:57

标签: mysql jsp sweetalert

我正在一个项目上,我想在删除帐户之前发出警报,我的问题是即使我单击“取消”,该帐户还是会被删除,请帮帮我。这是代码的一部分

<script>     
    swal({
        title: 'Êtes-vous sûr de vouloir supprimer ce compte?',
            text: 'You will not be able to recover this imaginary file!',
            type: 'warning',
            showCancelButton: true,
            confirmButtonColor: '#3085d6',
             cancelButtonColor: '#d33',
                confirmButtonText: 'Oui',
                cancelButtonText: 'Non',
                confirmButtonClass: 'confirm-class',
                cancelButtonClass: 'cancel-class',
                 closeOnConfirm: false,
                closeOnCancel: false    
                },
                function(isConfirm) {
             if (!isConfirm)
             {

                 window.location.href="AdminPlatform.jsp";
            } 
        else  {   
              swal(

                    'Deleted!',
                    'Your file has been deleted.',
                    'success'

                    ) ;

             <% int id=Integer.parseInt(request.getParameter("id"));
                      ConnectionAdmin.delete(id); 
             %>

          }
    });

    const swalWithBootstrapButtons = Swal.mixin({
    customClass: {
        confirmButton: 'btn btn-success',
        cancelButton: 'btn btn-danger'
    },
    buttonsStyling: false,
})     
 </script>

0 个答案:

没有答案