On This Date...

J

John Lund

How does one write JavaScript code for an image of something that happened
or appeared on this date? For example, today (as I'm writing this) is
October 2nd, and I would like to have an image of something that happened on
October 2nd.


-- John Lund
 
E

Evertjan.

How does one write JavaScript code for an image of something that
happened or appeared on this date? For example, today (as I'm writing
this) is October 2nd, and I would like to have an image of something
that happened on October 2nd.


<script>
function two(x) {return ((x>9)?"":"0")+x}
d = new Date();
img = "happened"+two(getMonth(d)+1)+two(getDate(d))+".jpg"
document.write("<img src='"+img+"'>")
// This shows the image "happened1002.jpg" on your date
</script>

not tested!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,102
Messages
2,570,645
Members
47,245
Latest member
ShannonEat

Latest Threads

Top