Forum Moderators: open
in the head of the html:
<script type="text/javascript">
var now = new Date();
var month = new String(now.getMonth());
var day = new String(now.getDate());
if (month.length!= 2) {month = "0" + month;}
if (day.length!= 2) {day = "0" + day;}
var img = month + "-" + day;
</script>
and in the body of the html:
<script type="text/javascript">
document.write("<img src='http://www.example.com/bg/' + img + '.jpg' alt=''>");
</script>
If you go to the directory [example.com...] you will see images.
The script should be calling for 02-07.jpg in this directory, (since we are february 7th) and the image is there, but it won't load...
I hope someone can see what's wrong...
Thanks,
Me-Uzik
[edited by: korkus2000 at 12:44 am (utc) on Feb. 8, 2004]
[edit reason] examplified URLs [/edit]
The below version works now:
<script type="text/javascript">
var now = new Date();
var month = now.getMonth();
month = month + 1;
var day = now.getDate());
if (month.length!= 2) {month = "0" + month;}
if (day.length!= 2) {day = "0" + day;}
alert (day + '\n' + month);
var img = month + "-" + day;
alert (img);
</script>
<script type="text/javascript">
document.write("<img src='" + img + ".jpg' alt=''>");
</script>
<IMG src="<?= date ("m-d")?>.jpg" alt="">
The main problem with developing in PHP is having to set up your own home apache webserver with PHP, that's not always super easy to do, but it is much more reliable in terms of being sure your code runs as consistently as possible, since javascript can be turned off, and sometimes is.
Me-Uzik
Thanks,
Me-Uzik
<script type="text/javascript">
var now = new Date();
var month = now.getMonth() + 1;
var day = now.getDate();
month = new String( month );
day = new String( day );
if (month.length < 2) {month = "0" + month;}
if (day.length < 2) {day = "0" + day;}
alert (day + '\n' + month);
var img = month + "-" + day;
alert (img);
</script>
<script type="text/javascript">
document.write("<img src='" + img + ".jpg' alt=''>");
</script>