document.addEventListener('DOMContentLoaded', function () { const fileUploadInput = document.getElementById('fileUpload'); const printOptionsModal = new bootstrap.Modal(document.getElementById('printOptionsModal')); const uploadForm = document.getElementById('uploadForm'); const fileNameSpan = document.getElementById('fileName'); const filePreview = document.getElementById('filePreview'); fileUploadInput.addEventListener('change', function () { if (this.files && this.files[0]) { const file = this.files[0]; fileNameSpan.textContent = file.name; // Simple preview for images if (file.type.startsWith('image/')) { const reader = new FileReader(); reader.onload = function (e) { filePreview.innerHTML = `File preview`; }; reader.readAsDataURL(file); } else { // Placeholder for non-image files filePreview.innerHTML = ''; } printOptionsModal.show(); } }); // Optional: If you want the form to submit from the modal button // const confirmPrintBtn = document.getElementById('confirmPrintBtn'); // confirmPrintBtn.addEventListener('click', function () { // uploadForm.submit(); // }); });