View Full Version : slideshow to read images from directory, not array

08-11-2004, 12:58 AM
is there a way to get a slideshow to read every image from a directory (folder)... and avoid me having to type 65 image names into an array?

if there is no way, how can i just copy all the files and say "paste names" into a .txt file (like how irc servers have a downloadable .txt of every file they have)

08-11-2004, 01:52 AM
Server side scripting is the answer

08-11-2004, 02:20 AM
Is there anything that would preclude you from naming the images sequentially, like:


If not, then just reference them like this:


var imgCnt = 66;

function Imgs(){

var oImg = new Image();
for (var i=1;i<imgCnt;i++){
oImg.src = "images/image" + i + ".gif";
window.onload = Imgs;


That's just an example though. But it depends on how you want to use them, like, what does slideshow mean to you? Are the images going to be preloaded, will the slideshow advance automatically, using setInterval(), or will it be interactive, like when someone clicks on a button, etc.?


08-11-2004, 01:50 PM
I think that ^ would be the best way to do it. Though I think a for loop will display all the images in like half a second.

var x = 1

function imgs()
myImg.src = "images/image" +x+ ".gif"
if(x==60) clearInterval(intV)

var intV = setInterval("imgs()",3000);

If you want to go server side you might want to look at this (http://www.w3schools.com/asp/coll_files.asp)

08-11-2004, 04:08 PM
sweet, lemme see what i can drum up with that asp script