Rotating Images Code Help Please

I am trying to rotate 5 images (each linking to a page on my website) but the code doesnt seem to work when I put in inside a table.
Anyone have any idea where I am going wrong please?

This is the code in <head> section

<script language=“JavaScript1.2”>

var howOften = 5; //number often in seconds to rotate
var current = 0; //start the counter at 0
var ns6 = document.getElementById&&!document.all; //detect netscape 6

// place your images, text, etc in the array elements here
var items = new Array();
items[0]=“<a href=‘commercial_cleaning.htm’ ><img alt=‘image0 (9K)’ src=‘rotate/image0.jpg’ border=‘0’ /></a>”; //a linked image
items[1]=“<a href=‘recycle_units.htm’><img alt=‘image1 (9K)’ src=‘rotate/image1.jpg’ border=‘0’ /></a>”; //a linked image
items[2]=“<a href=‘pest_control.htm’><img alt=‘image2 (9K)’ src=‘rotate/image2.jpg’ border=‘0’ /></a>”; //a linked image
items[3]=“<a href=‘washroom_services.htm’><img alt=‘image3 (9K)’ src=‘rotate/image3.jpg’ border=‘0’ /></a>”; //a linked image
items[4]=“<a href=‘window_cleaning.htm’><img alt=‘image4 (9K)’ src=‘rotate/image4.jpg’ border=‘0’ /></a>”; //a linked image
function rotater() {
document.getElementById(“placeholder”).innerHTML = items[current];
current = (current==items.length-1) ? 0 : current + 1;
setTimeout(“rotater()”,howOften*1000);
}

function rotater() {
if(document.layers) {
document.placeholderlayer.document.write(items[current]);
document.placeholderlayer.document.close();
}
if(ns6)document.getElementById(“placeholderdiv”).innerHTML=items[current]
if(document.all)
placeholderdiv.innerHTML=items[current];

current = (current==items.length-1) ? 0 : current + 1; //increment or reset
setTimeout("rotater()",howOften*1000);

}
window.onload=rotater;
//–>
</script>

and in body section (incide table) this code <layer id=“placeholderlayer”></layer><div id=“placeholderdiv”></div>

Thanks in advance, any help greatly appreciated

Hi, would help if you could specify why its failing. Is it an error, or are the images simply not loading?=

sorry - yes images are not loading at all , can be seen on this test page http://blitz-it.co.uk/test_page.htm

thanks

Your code is working, but I’m getting a 404 error on your images. I think you just need to check the addresses to your files.

Example: http://blitz-it.co.uk/rotate/image0.jpg

There are 2 functions there named ‘rotator’.

The second one is riddled with antiquated layers code and document.all code.
Delete that entire function, plus the var = ns6 declaration near the top, plus the <layer> tag in the markup.
Wipe them all totally, as they belong to the Netscape 4 / IE 4 era of the late 1990s.

Now, the remaining problem in the surviving ‘rotator’ function will show up in your browser error console,
but here it is too:

<div id=“placeholderdiv”>

function rotater() {
document.getElementById(“placeholder”)

This is all aside from any problems you may be having with image locations and loading,
but try fixing the above and see where that takes you.

sorry i am new at java, i have changed the code as follows and still not working

<script language=“JavaScript1.2”>

var howOften = 5;
var current = 0;
var ns6 = document.getElementById&&!document.all;
var items = new Array();
items[0]=“<a href=‘/commercial_cleaning.htm’ ><img src=‘0.jpg’ border=‘0’ /></a>”; //a linked image
items[1]=“<a href=‘/recycle_units.htm’><img src=‘1.jpg’ border=‘0’ /></a>”; //a linked image
items[2]=“<a href=‘/pest_control.htm’><img src=‘2.jpg’ border=‘0’ /></a>”; //a linked image
items[3]=“<a href=‘/washroom_services.htm’><img src=‘3.jpg’ border=‘0’ /></a>”; //a linked image
items[4]=“<a href=‘/window_cleaning.htm’><img src=‘4.jpg’ border=‘0’ /></a>”; //a linked image
function rotater() {
document.getElementById(“placeholder”).innerHTML = items[current];
current = (current==items.length-1) ? 0 : current + 1;
setTimeout(“rotater()”,howOften*1000);
}

function rotater() {
if(document.layers) {
document.placeholderlayer.document.write(items[current]);
document.placeholderlayer.document.close();
}
if(ns6)document.getElementById(“placeholderdiv”).innerHTML=items[current]
if(document.all)
placeholderdiv.innerHTML=items[current];

current = (current==items.length-1) ? 0 : current + 1;
setTimeout(“rotater()”,howOften*1000);
}
window.onload=rotater;
//–>
</script>

help please x

thanks for all your help, have now sorted the problem

Awesome, gled to hear that. What was it?

all i needed to do was put the full url of each image !