Loan Summary
${summaryHTML}
Amortization Schedule
${scheduleTableHTML}
Generated on: ${new Date().toLocaleDateString()} ${new Date().toLocaleTimeString()}
`;
const printWindow = window.open('', '_blank');
if (printWindow) {
printWindow.document.write('
Mortgage Amortization Report');
printWindow.document.write(pdfContent);
printWindow.document.write('');
printWindow.document.close();
printWindow.focus();
setTimeout(() => { printWindow.print(); }, 500); // Increased timeout for potentially large tables
} else {
alert('Could not open print window. Please check your browser pop-up settings.');
}
});
[loanAmountInput, annualInterestRateInput, loanTermYearsInput, extraMonthlyPaymentInput].forEach(inputEl => {
if (inputEl) {
inputEl.addEventListener('focus', function() {
const errorElId = `mac${this.id.substring(3)}Error`;
const errorDisplay = document.getElementById(errorElId);
if (errorDisplay) errorDisplay.textContent = '';
});
}
});
});