Indian Wedding Budget Calculator | Plan Your Dream Wedding
` ;
// Write content to new window
printWindow.document.write(pdfContent);
printWindow.document.close();// Wait for content to load then print
printWindow.onload = function() {
printWindow.print();
// Optional: close the window after printing
// printWindow.close();
};
}// Generate budget tips
function generateTips() {
const tips = [
'Book venues during off-season for better rates',
'Compare multiple vendor quotes before finalizing',
'Consider combining events to reduce overall costs',
'Optimize guest list for better cost management',
'Plan menu thoughtfully to minimize food wastage',
'Book services well in advance for better rates'
];const tipsContainer = document.getElementById('tips-container');
tips.forEach(tip => {
const tipCard = document.createElement('div');
tipCard.className = 'tip-card';
tipCard.textContent = tip;
tipsContainer.appendChild(tipCard);
});
}
// Add this reset function
function resetCalculator() {
// Show confirmation dialog
if (confirm('Are you sure you want to clear all data? This action cannot be undone.')) {
// Reset all input fields
document.querySelectorAll('input[type="number"], input[type="text"]').forEach(input => {
input.value = '';
});// Reset total budget and guest count
document.getElementById('total-budget').value = '';
document.getElementById('guest-count').value = '';// Reset summary displays
document.getElementById('total-spent').textContent = `${currentSymbol}0`;
document.getElementById('per-guest-cost').textContent = `${currentSymbol}0`;// Reset progress bar
const progressBar = document.getElementById('budget-progress');
progressBar.style.width = '0%';
progressBar.style.backgroundColor = 'var(--secondary-color)';// Reset charts
if (window.expenseChart) {
window.expenseChart.data.labels = [];
window.expenseChart.data.datasets[0].data = [];
window.expenseChart.update();
}
if (window.budgetChart) {
window.budgetChart.data.datasets[0].data = [0, 0];
window.budgetChart.update();
}// Remove any budget alerts
const existingAlert = document.querySelector('.budget-alert');
if (existingAlert) {
existingAlert.remove();
}// Reset currency to default (INR)
currentCurrency = 'INR';
currentSymbol = '₹';
document.querySelectorAll('.currency-btn').forEach(btn => {
btn.classList.remove('active');
if (btn.dataset.currency === 'INR') {
btn.classList.add('active');
}
});// Optional: Show success message
const successAlert = document.createElement('div');
successAlert.style.cssText = `
position: fixed;
top: 20px;
right: 20px;
background-color: #dcfce7;
color: #166534;
padding: 1rem;
border-radius: 0.5rem;
box-shadow: 0 2px 4px rgba(0,0,0,0.1);
z-index: 1000;
` ;
successAlert.textContent = 'All data has been cleared successfully!';
document.body.appendChild(successAlert);// Remove success message after 3 seconds
setTimeout(() => {
successAlert.remove();
}, 3000);
}
}// Initialize the calculator when the page loads
window.addEventListener('load', initializeCalculator);