PDA

View Full Version : Javascript Day of Month Image



Boonzeet
25-12-2009, 02:34 AM
http://tekcube.net/wp-content/themes/tekcube/thing.php

This is a date calendar I'm using, and it works great... for people living in Texas, where my server is. I want one that shows the users date, so I started coding in Javascript. I've gotten this far, but I don't know how to display an image depending on the actual DAY.

The date images are capitalized 3-letter names, i.e. Dec, Mar, Apr.

The day images are numbers without leading zeroes, i.e. 1, 9, 25.

Here's the PHP:

<img src="/images/date/<?php echo date("M"); ?>.jpg" alt="<?php echo date("M"); ?>" /><br /><img src="/images/date/<?php echo date("j"); ?>.jpg">

Here's the Javascript so far:

<script language="javascript" type="text/javascript">
var months = new Array('Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec');
var thetime = new Date();
var themonth = thetime.getMonth();
document.write('<img src="/images/date/' + months[themonth] + '.jpeg" alt="' + months[themonth] + '" />');
</script>

I have Googled this relentlessly and came to no avail.

Thanks, Boonzeet.

Want to hide these adverts? Register an account for free!