Aggiungi Prodotto Finito

Aggiungi Prodotto Finito

Inserisci le informazioni del prodotto finito

Formati supportati: JPEG, PNG, JPG, GIF, WEBP (max 5MB)

Annulla
`); printWindow.document.close(); } // Anteprima foto document.getElementById('foto').addEventListener('change', function(e) { const file = e.target.files[0]; const preview = document.getElementById('foto-preview'); const previewImg = document.getElementById('foto-preview-img'); if (file) { const reader = new FileReader(); reader.onload = function(e) { previewImg.src = e.target.result; preview.classList.remove('hidden'); }; reader.readAsDataURL(file); } else { preview.classList.add('hidden'); } }); // Rimuovi documenti vuoti prima dell'invio del form document.querySelector('form').addEventListener('submit', function(e) { const container = document.getElementById('documents-container'); const documentItems = container.querySelectorAll('.document-item'); documentItems.forEach(function(item) { const fileInput = item.querySelector('input[type="file"]'); // Se non c'è un file selezionato, rimuovi tutti i campi del documento if (!fileInput || !fileInput.files || fileInput.files.length === 0) { // Rimuovi tutti gli input del documento per evitare che vengano inviati item.querySelectorAll('input, select, textarea').forEach(function(input) { input.remove(); }); // Rimuovi l'intero elemento item.remove(); } }); });