Hey everybody. I have a script that I've been working on that just doesn't work. I'm a beginner so it might be an easy fix and it might not.
On javascript.internet.com there are some scripts that give a "quote of the day", "random image", and "tip of the day". I took portions from each of these scripts in a vain effort to try to create a script that will show a selected image on a previously specified day.
However, I keep getting an "undefined" error, and even when I get no error, no image pops up. What's wrong with this script:
<SCRIPT LANGUAGE="JavaScript">
<!-- Begin
var theImages = new Array()
Stamp = new Date();
today = Stamp.getDate();
theImages[1] = '2.jpg';
theImages[2] = '3.jpg';
theImages[3] = '4.jpg';
theImages[4] = '5.jpg';
theImages[5] = '6.jpg';
theImages[6] = '7.jpg';
theImages[7] = '8.jpg';
theImages[8] = '9.jpg';
theImages[9] = '10.jpg';
theImages[10] = '11.jpg';
theImages[11] = '12.jpg';
theImages[12] = '13.jpg';
theImages[13] = '14.jpg';
theImages[14] = '15.jpg';
theImages[15] = '16.jpg';
theImages[16] = '17.jpg';
theImages[17] = '18.jpg';
theImages[18] = '19.jpg';
theImages[19] = '20.jpg';
theImages[20] = '1.jpg';
theImages[21] = '2.jpg';
theImages[22] = '3.jpg';
theImages[23] = '4.jpg';
theImages[24] = '5.jpg';
theImages[25] = '6.jpg';
theImages[26] = '7.jpg';
theImages[27] = '8.jpg';
theImages[28] = '9.jpg';
theImages[29] = '10.jpg';
theImages[30] = '11.jpg';
theImages[31] = '12.jpg';
var whichImage = ('<i>' + theImages[today] + '</i><br>');
function showImage(){
document.write('<img src=http://www.webdeveloper.com/forum/archive/index.php/"'+theImages[whichImage]+'">');
}
// End -->
</script>
<body>
<p>
<b>Picture of the Day:</b>
<script>
showImage();
</script>
I think the problem is in the "var whichImage = ...." part, but I don't know how to define "whichImage"! I'm very much a beginner and I would appreciate anyone's help that I can get on this!
Thanks in advance!
Krismisz
On javascript.internet.com there are some scripts that give a "quote of the day", "random image", and "tip of the day". I took portions from each of these scripts in a vain effort to try to create a script that will show a selected image on a previously specified day.
However, I keep getting an "undefined" error, and even when I get no error, no image pops up. What's wrong with this script:
<SCRIPT LANGUAGE="JavaScript">
<!-- Begin
var theImages = new Array()
Stamp = new Date();
today = Stamp.getDate();
theImages[1] = '2.jpg';
theImages[2] = '3.jpg';
theImages[3] = '4.jpg';
theImages[4] = '5.jpg';
theImages[5] = '6.jpg';
theImages[6] = '7.jpg';
theImages[7] = '8.jpg';
theImages[8] = '9.jpg';
theImages[9] = '10.jpg';
theImages[10] = '11.jpg';
theImages[11] = '12.jpg';
theImages[12] = '13.jpg';
theImages[13] = '14.jpg';
theImages[14] = '15.jpg';
theImages[15] = '16.jpg';
theImages[16] = '17.jpg';
theImages[17] = '18.jpg';
theImages[18] = '19.jpg';
theImages[19] = '20.jpg';
theImages[20] = '1.jpg';
theImages[21] = '2.jpg';
theImages[22] = '3.jpg';
theImages[23] = '4.jpg';
theImages[24] = '5.jpg';
theImages[25] = '6.jpg';
theImages[26] = '7.jpg';
theImages[27] = '8.jpg';
theImages[28] = '9.jpg';
theImages[29] = '10.jpg';
theImages[30] = '11.jpg';
theImages[31] = '12.jpg';
var whichImage = ('<i>' + theImages[today] + '</i><br>');
function showImage(){
document.write('<img src=http://www.webdeveloper.com/forum/archive/index.php/"'+theImages[whichImage]+'">');
}
// End -->
</script>
<body>
<p>
<b>Picture of the Day:</b>
<script>
showImage();
</script>
I think the problem is in the "var whichImage = ...." part, but I don't know how to define "whichImage"! I'm very much a beginner and I would appreciate anyone's help that I can get on this!
Thanks in advance!
Krismisz