views:

31

answers:

1

I have a series of images (named as image_1.jpg, image_2.jpg and so on) in a folder. How can all of the images be joined together to form an HTML page using Javascript?

A: 

Just add:

<img src="path/to/your/image_1" alt="image_1" />
<img src="path/to/your/image_2" alt="image_2" />
<img src="path/to/your/image_3" alt="image_3" />

etc...

EDIT:

for(var i = 1 ; i < TOTAL_IMAGES ; i ++ )
{
  var img = document.createElement('img');
  img.src = "path/to/your/image_" + i;
  img.alt = "image number " + i;
  document.appendChild(img);  // this will append the image to the root element. You might want to use a <div> or something instead.
}
Pablo Fernandez
Thanks for the reply... but actually I have lots of images to add (around 200). I want to add those images using JavaScript (using for loop) but I am unable to do so...
kool4u
Ok, let me edit the answer
Pablo Fernandez
Thanks a lot...this is working !!!
kool4u