I'm new to Javascript and want to write a script which will loop through the files in a folder and display them in a webpage. I've written the following which alternately displays two images in a folder, but I want to be able to add new files to that folder and have them added to this loop. I'm assuming I just need some code to populate the list of files in the folder, but don't know how to do that, nor how to make var have a variable max depending on the number of files. This will all be displayed locally, so there's no kind of web server.
How might I do this?
Thanks very much for your help
Code:
<html>
<head>
<title>CMM Reference Part Check Compliance</Title>
<script type="text/javascript">
<!--
var image1=new Image()
image1.src="Slide1.gif"
var image2=new Image()
image2.src="Slide2.gif"
//-->
</script>
</head>
<body>
<img src="Slide1.gif" name="slide" width="95%" height="95%" />
<script>
<!--
//variable that will increment through the images
var step=1
function slideit() {
//if browser does not support the image object, exit.
if (!document.images)
return
document.images.slide.src=eval("image"+step+".src")
if (step<2)
step++
else
step=1
//call function "slideit()" every 10 seconds
setTimeout("slideit()",1000)
}
slideit()
//-->
</script>
</body>
</html>
Thanks very much for your help
Comment