$('.show_confirm').click(function(event) { var form = $(this).closest("form"); var name = $(this).data("name"); event.preventDefault(); swal({ title: `Are you sure you want to delete this record?` , text: "If you delete this, it will be gone forever." , icon: "warning" , buttons: true , dangerMode: true , }) .then((willDelete) => { if (willDelete) { form.submit(); } }); }); function myFunction() { document.getElementById("demo").innerHTML = "Hello World"; } var myModal = document.getElementById('myModal') var myInput = document.getElementById('myInput') myModal.addEventListener('shown.bs.modal', function() { myInput.focus() }) $('form input').on('change', function() { $(this).closest('form').submit(); }); $(function() { $('.toggle-class').change(function() { var etat = $(this).prop('checked') == true ? 1 : 0; var Id = $(this).data('id'); $.ajax({ type: "GET" , dataType: "json" , url: '/changeStatusPresentation' , data: { 'etat': etat , 'Id': Id } , success: function(data) { console.log(data.success) } }); }) })