Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Image Slide Show

Status
Not open for further replies.

nsukari

Technical User
Jul 17, 2002
26
0
0
US
I am using the following script from javascriptkit.com for a slideshow. I need to know if there is a way for me to point to an entire directory of photos instead of listing the photos seperately. I am often replacing photos or adding new ones and instead of having to update my script each time, it would be great if I could tell the script to run the slide show based on all of the images in the "Photos" directory instead of listing each photo individually. I would apprecaite any feedback.

<script language=&quot;JavaScript1.1&quot;>
<!--

var slideimages=new Array()
var slidelinks=new Array()
function slideshowimages(){
for (i=0;i<slideshowimages.arguments.length;i++){
slideimages=new Image()
slideimages.src=slideshowimages.arguments
}
}

function slideshowlinks(){
for (i=0;i<slideshowlinks.arguments.length;i++)
slidelinks=slideshowlinks.arguments
}

function gotoshow(){
if (!window.winslide||winslide.closed)
winslide=window.open(slidelinks[whichlink])
else
winslide.location=slidelinks[whichlink]
winslide.focus()
}

//-->
</script>
</head>
<body bgcolor=&quot;#000000&quot;><center><a href=&quot;javascript:gotoshow()&quot;><img src=&quot;DCP_0301.jpg&quot; name=&quot;slide&quot; border=0></a>
<script>
<!--

//configure the paths of the images, plus corresponding target links
slideshowimages(&quot;DCP_0301.jpg&quot;,&quot;awas_2.jpg&quot;,&quot;DCP_0292.jpg&quot;,&quot;DCP_0293.jpg&quot;,&quot;DCP_0294.jpg&quot;,&quot;DCP_0295.jpg&quot;,&quot;DCP_0296.jpg&quot;,&quot;DCP_0297.jpg&quot;,
&quot;DCP_0298.jpg&quot;,&quot;DCP_0299.jpg&quot;,&quot;DCP_0300.jpg&quot;,&quot;awas_1.jpg&quot;,&quot;talking_7.jpg&quot;,&quot;DCP_0303.jpg&quot;,&quot;DCP_0304.jpg&quot;,&quot;DCP_0305.jpg&quot;,
&quot;DCP_0306.jpg&quot;,&quot;ed_1.jpg&quot;,&quot;ed_2.jpg&quot;,&quot;ed_.jpg&quot;,&quot;talking_1.jpg&quot;,
&quot;talking_2.jpg&quot;,&quot;talking_3.jpg&quot;,&quot;talking_4.jpg&quot;,&quot;talking_5.jpg&quot;,&quot;talking_6.jpg&quot;,&quot;DCP_0302.jpg&quot;,&quot;Town_01.jpg&quot;,&quot;Town_02.jpg&quot;,
&quot;Town_05.jpg&quot;,&quot;Town_06.jpg&quot;,&quot;Town_07.jpg&quot;,&quot;Town_08.jpg&quot;,&quot;Town_09.jpg&quot;,&quot;Town_10.jpg&quot;,&quot;Town_12.jpg&quot;,&quot;Town_14.jpg&quot;,&quot;Town_15.jpg&quot;,&quot;Town_16.jpg&quot;)

//configure the speed of the slideshow, in miliseconds
var slideshowspeed=5000

var whichlink=0
var whichimage=0
function slideit(){
if (!document.images)
return
document.images.slide.src=slideimages[whichimage].src
whichlink=whichimage
if (whichimage<slideimages.length-1)
whichimage++
else
whichimage=0
setTimeout(&quot;slideit()&quot;,slideshowspeed)
}
slideit()

//-->
</script>
 
nsukari,

This is the hard way of doing it:

Write a Perl script that sits on your server. When called, the script does a catalog of the directory, parses out the file names, and composes the appropriate HTML page(s) and writes the new HTML file(s).

Whenever you add to or take away from your online list of images, just call this script from a browser and a few seconds (at most) later, all your web pages are updated.

But this is just writing a Perl script to do the dum-dum thing I would do if I were redoing this by hand.

Good luck!
[monkey] Edward [monkey]

&quot;Cut a hole in the door. Hang a flap. Criminy, why didn't I think of this earlier?!&quot; -- inventor of the cat door
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top