469,289 Members | 2,184 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,289 developers. It's quick & easy.

Javascript: Get a list of photos

Ok I want to create an array of photos that are in a specific directory of the web server is their a way to get the list of files and store it into an array? thanks

i tried

Expand|Select|Wrap|Line Numbers
  1. var pictureID;
  2.  
  3. document.onload
  4. {
  5.  
  6.     pictureID = 0;
  7.     var pictures = new Array("balls.jpg", "kids.jpg", "kids2.jpg" )
  8.     document.write("hi");
  9.     document[thispicture].src = "test";
  10.         document.write("hi");
  11.  
  12. }
but it wouldnt allow me to change the src of the thispicture img tag
May 3 '09 #1
1 1550
acoder
16,027 Expert Mod 8TB
For your original query, the answer is: not with JavaScript. Use your server-side language, e.g. PHP, ASP, etc.

In your code, change line 3 to
Expand|Select|Wrap|Line Numbers
  1. window.onload = function()
Is thispicture a variable? If not, and the name of the image is thispicture, you can use
Expand|Select|Wrap|Line Numbers
  1. document.images["thispicture"].src = ...
You also need to use a valid image file name/path.
May 3 '09 #2

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

10 posts views Thread by John Ortt | last post: by
1 post views Thread by Gary | last post: by
2 posts views Thread by mr.mattyg | last post: by
1 post views Thread by CARIGAR | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.