Click to See Complete Forum and Search --> : schedule image wont work...


crash
10-11-2003, 12:02 AM
I added a script to this page and it won't display the picture thats based on a schedule on http://www3.mb.sympatico.ca/~jgiesbrt/freq107/index.htm Does anyone have any suggestions, Here's the script i added:
<img src="onairpics\images\on_air_overnight.gif" onload="setImage(this)">

<script type="text/javascript">
function setImage(img){
var now = new Date();
var day = now.getDay();
var hours = now.getHours();

if (day == 0){ // Sunday pics
if (hours < 9){
img.src = 'onairpics\images\on_air_overnight.gif';
} else if (hours < 15){
img.src = 'onairpics\images\on_air_crash.gif';
} else if (hours < 21){
img.src = 'onairpics\images\on_air_doug.gif';
} else {
img.src = 'onairpics\images\on_air_overnight.gif';
}
} else if (day == 6){ // Saturday pics
if (hours < 9){
img.src = 'onairpics\images\on_air_overnight.gif';
} else if (hours < 15){
img.src = 'onairpics\images\on_air_doug.gif';
} else if (hours < 21){
img.src = 'onairpics\images\on_air_crash.gif';
} else {
img.src = 'onairpics\images\on_air_overnight.gif';
}
} else { // Mon - Fri pics
if (hours < 6){
img.src = 'onairpics\images\on_air_overnight.gif';
} else if (hours < 10){
img.src = 'onairpics\images\on_air_brian.gif';
} else if (hours < 15){
img.src = 'onairpics\images\on_air_gen.gif';
} else if (hours < 19){
img.src = 'onairpics\images\on_air_buzz.gif';
} else {
img.src = 'onairpics\images\on_air_steve.gif';
}
}
}
</script>

Hope you can help
I'm stumped!

David Harrison
10-11-2003, 04:35 PM
I think that this should go into the body tag:

onload="setImage(this)"

and of course you won't be able to put "this" in the brackets. I would suggest doing this:

<script type="text/javascript"><!--
function setImage(){

img=document.getElementById("an_img");

...

//--></script>

</head>

<body onload="setImage();">

<img src="onairpics\images\on_air_overnight.gif" alt="on air overnight">

By the way, the page you gave an address to was a 404 page not found.

crash
10-11-2003, 04:53 PM
hey sorry bout that, i was just updating. I'll try those scripts and see if they work.

thx

here's the site


web page (http://www3.mb.sympatico.ca/~jgiesbrt/Freq107/)

crash
10-11-2003, 05:38 PM
I tride those codes everywhere and they're not working. if you could check out the site and view source and see what i should change that would be awesome.

thanks again,

Aronya1
10-13-2003, 06:36 PM
Your path is wrong. The image is in the 'onairpics' folder, not in onairpics/images.

Get the path right & remove the 'onload="setImage(this)"' part, & it comes up fine.