With this code all you need add to the <img> tags is a unique ID.
This example controls cycling of images in two different image placeholders with IDs 'firstIimage' and 'secondImage'.
Code:
<script type='text/javascript'>
function CycleClick(imgHolder, imgArray)
{
this.size=imgArray.length
this.data = [];
this.pos = 0;
this.imgHolder = document.getElementById(imgHolder);
for(var i=0, len=this.size; i<len; i++)
{
this.data[i] = new Image();
this.data[i].src = imgArray[i];
this.imgHolder.onclick=(function(inst){return function()
{
this.src = inst.data[inst.pos++].src;
inst.pos %= inst.size;
}})(this);
}
}
new CycleClick("firstImage", [ "image1.gif", "image2.gif", "image3.gif" ] );
new CycleClick("secondImage", [ "image4.gif", "image5.gif", "image6.gif" ] );
// Add more here as required
Bookmarks