...

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



canadianjameson
08-10-2004, 11:58 PM
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)

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

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

image1.gif
image2.gif
image3.gif
etc.

If not, then just reference them like this:



<script>
<!--

var imgCnt = 66;

function Imgs(){

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

//-->
</script>

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.?



-james

JPM
08-11-2004, 12: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"
x++;
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)
(asp)

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



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum