Work Anniversary & Birthday Greeting

Greeting Generator body { font-family: Arial, sans-serif; max-width: 480px; margin: 40px auto; } label, select, input, button { display: block; margin: 12px 0; width: 100%; } button { padding: 10px; background: #0073aa; color: white; border: none; cursor: pointer; font-size: 16px; } #message { margin-top: 20px; padding: 15px; background: #e0f7fa; border-radius: 6px; white-space: pre-wrap; }

Work Anniversary & Birthday Greeting Generator

Work Anniversary Birthday
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; }