screen_rotation
Copied to Clipboard
<!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Bootstrap 5 Modal Example</title> <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.2.1/dist/css/bootstrap.min.css" rel="stylesheet"> </head> <body> <h3>Bootstrap Confirm Delete Modal | Popup</h3> <button type="button" class="btn btn-danger" data-bs-toggle="modal" data-bs-target="#deleteModal" onclick="confirmDeleteModal('10')">Delete Item id 10</button> <div class="modal fade" id="deleteModal" tabindex="-1" role="dialog" aria-labelledby="deleteModalLabel" aria-hidden="true"> <div class="modal-dialog" role="document"> <div class="modal-content"> <div class="modal-header"> <h5 class="modal-title" id="deleteModalLabel">Confirm Deletion</h5> <button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button> </div> <div class="modal-body"> Are you sure you want to delete this item? </div> <div class="modal-footer"> <button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Cancel</button> <button type="button" class="btn btn-danger" id="confirmDelete">Delete</button> </div> </div> </div> </div> <!-- Toast Message --> <div class="toast align-items-center position-fixed bottom-0 end-0" role="alert" aria-live="assertive" aria-atomic="true" style="width: 300px;"> <div class="toast-header"> <strong class="me-auto">Bootstrap</strong> <small class="text-muted" id="toastTime"></small> <button type="button" class="btn-close" data-bs-dismiss="toast" aria-label="Close"></button> </div> <div class="toast-body"> Hello, world! This is a toast message. </div> </div> <script src="https://code.jquery.com/jquery-3.6.0.min.js"></script> <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.2.1/dist/js/bootstrap.bundle.min.js"></script> <script> function getCurrentTime() { const now = new Date(); const timeString = now.toLocaleTimeString([], { hour: '2-digit', minute: '2-digit' }); return timeString; } function confirmDeleteModal(itemId) { // Set the item ID in the modal body $("#deleteModal .modal-body").text("Are you sure you want to delete item ID: " + itemId + "?"); // Set the delete button's click event handler $("#confirmDelete").off("click").on("click", function () { // Perform the deletion logic here console.log("Deleting item ID: " + itemId); // Close the modal var deleteModal = bootstrap.Modal.getInstance(document.getElementById("deleteModal")); deleteModal.hide(); // Show the toast message var toast = $(".toast"); toast.find('.toast-body').text('Item 10 Deleted Successfully'); $("#toastTime").text(getCurrentTime()); toast.toast("show"); }); } </script> </body> </html>