document.getElementById("year").addEventListener("change", function () { const year = this.value; const downloadBtn = document.getElementById("downloadBtn"); const previewDiv = document.getElementById("preview"); const contentDiv = document.getElementById("previewContent"); if (!year) { downloadBtn.style.display = "none"; previewDiv.style.display = "none"; contentDiv.innerHTML = ""; return; } downloadBtn.href = `/summary/download?year=${year}`; downloadBtn.style.display = "inline-block"; fetch(`/summary/preview?year=${year}`) .then(res => res.json()) .then(data => { let html = ``; data.forEach(row => { html += ``; }); html += `
Particular ITR AO CIT ITAT
${row.Particular} ${row.ITR} ${row.AO} ${row.CIT} ${row.ITAT}
`; contentDiv.innerHTML = html; // Show preview previewDiv.style.display = "block"; }) .catch(err => console.error("Preview load error:", err)); });