views:

176

answers:

1

I am trying to make a scriptaculous slideshow but I have no idea how to loop over all the images in the div tag and then check if it is the last image and assign it to the first img. I can add the fading and whatnot myself but I have no idea how to loop through them.

A: 

How do you store the images for the slideshow? If you use arrays, then you are looking for imageArray.length. Also you may have a look at the source code for lightbox, as it uses prototype and scriptacolous as well and uses arrays for storing grouped images.

In pure JavaScript you would do something this to get the images as an array included in a div with an ID:

getImageArray = function(containerId) {
    var containerElement = document.getElementById(containerId);
    if (containerElement) {
        var imageArray = containerElement.getElementsByTagName("img");
        return imageArray;
    } else {
        return null; // or something similar
    }
}
Residuum