Click to See Complete Forum and Search --> : loading images w/o coding


nemex
12-10-2002, 03:40 PM
I have this script that automatically loads a number of images without all the coding.

<script language="javascript">
var numofimages = 10
for (x=1; x<numofimages; x++) {
document.write("<IMG SRC="+x+".jpg hspace=10>")}
</SCRIPT>

Here's my stupid question: what do I name my image(s)? I just have no idea and I've tried everything I could think of.

Another question: the script is set to display 10 images. How do I change it so that it displays all the images in my images directory? So when I upload a new image to the images dir, it will automatically display without having to change the "var numofimages" line.

Thanks in adv!!

Sceiron
12-10-2002, 04:11 PM
First, this script loops over a variable, x, from one to ten. So, your images would be 1.jpg, 2.jpg ... 10.jpg.

Second, you will need to adjust the variable with the correct number, as there is no simple way for the script to figure out how many images there are in your images directory. If I'm wrong on this point, someone please correct me, as I'd be interested to know how.