Best Credit Cards - Debt Consolidation - Car Credit - Flights - Life Insurance

PDA

View Full Version : code that shows whose birthday it is today


patr1c1a
Nov 14th 2006, 3:31 am
I'm looking for some javascript code that shows whose birthday is every day.
Something that tells me: "today is [xxx's] birthday"
where I can set a person's name for each day/month of the year.
I couldn't find anything like that, other than full calendars where the user has to pick the day or something. I only need it to tell on each day whose birthday is.

lucianp
Nov 14th 2006, 6:01 am
That's because nobody has thinking for something so simple...

nico_swd
Nov 14th 2006, 9:17 am
Try this. Just add the birthdays like in the example.


<div id="birthday">Today's birthday: </div>

<script type="text/javascript">
<!--
var birthdays = new Array();

birthdays['2006-11-14'] = 'Someone';
birthdays['2006-11-15'] = 'Someone else';
birthdays['2006-11-16'] = 'Who knows';


var date = new Date();
var day = date.getDate();
var month = date.getMonth()+1;
var year = date.getFullYear();
var birthday = birthdays[year +'-'+ month +'-'+ day] ? birthdays[year +'-'+ month +'-'+ day] : 'None';
document.getElementById('birthday').innerHTML += birthday;

//-->
</script>