const extraFieldsDiv = document.getElementById('extraFields');
const occasionSelect = document.getElementById('occasion');
function updateExtraFields() {
const occasion = occasionSelect.value;
if (occasion === 'work') {
extraFieldsDiv.innerHTML = `
`;
} else {
extraFieldsDiv.innerHTML = `
`;
}
}
occasionSelect.addEventListener('change', updateExtraFields);
updateExtraFields();
function generateGreeting() {
const name = document.getElementById('name').value.trim();
const occasion = occasionSelect.value;
const years = document.getElementById('years') ? document.getElementById('years').value.trim() : '';
const age = document.getElementById('age') ? document.getElementById('age').value.trim() : '';
if (!name) {
alert('Please enter the name.');
return;
}
let message = '';
if (occasion === 'work') {
if (!years || years <= 0) {
alert('Please enter valid years at company.');
return;
}
message = `🎉 Happy Work Anniversary, ${name}! 🎉
Congratulations on completing ${years} ${years == 1 ? 'year' : 'years'} with us. Your dedication and hard work inspire the whole team. Wishing you many more successful years ahead! 🚀`;
} else {
message = `🎂 Happy Birthday, ${name}! 🎂
Wishing you a fantastic day filled with joy and a year ahead full of success and happiness.${age ? ` Can't believe you’re ${age} already!` : ''} Enjoy your special day! 🎉🎈`;
}
document.getElementById('message').textContent = message;
}