PDA

View Full Version : Trying to Link Rotating Images



lataylor
01-31-2011, 10:37 PM
Hello Everyone!

There are several other pages over a span of sites that deal with this matter, but none that seem to work for me. So I'm hoping you guys can help.

I'm trying to get a set of rotating images to house a set of links that visitors can click on.

Here's code I slapped together:



<script language="javascript" type="text/javascript">

var imgArray = new Array();
// Enter the names of the images below
imgArray[0]="http://www.555.com/file.JPG";
imgArray[1]="http://www.555.com/file.JPG";
imgArray[2]="http://www.555.com/file.JPG";


// Set up URL array
var URL = new Array();
URL[0] = "http://www.555.com";
URL[1] = "http://www.555.com";
URL[2] = "http://www.555.com";



var newImage = 0 ;
var totalImg = imgArray.length ;
var currentURL = (URL.length - 1);

function cycleImg() {
if (newImage == totalImg) {
newImage = 0 ;
} else {
document.image.src = imgArray[newImage];
document.image.URL = URL[a] ;
// set the time below for length of image display
// i.e., "4*1000" is 4 seconds
setTimeout("cycleImg()", 3*1000);

newImage++;
}

}

</script>

<body onload="cycleImg();">
<div id="rotator_div">
<p style="text-align:center;"> <strong>Current Sponsors:</strong></p>
<img id="rotating_img" src="http://www.555.com/file.JPG" name="image"/>
</div>
</body>


Now it only loads the first image, and disappears; plus the image that does load, doesn't have the corresponding URL attached to it in as a link.

Could anyone please help with the adjustments that I need to make to pull this off? Thanks very much in advance.