471,831 Members | 1,658 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,831 software developers and data experts.

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;
  3. document.onload
  4. {
  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");
  12. }
but it wouldnt allow me to change the src of the thispicture img tag
May 3 '09 #1
1 1583
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.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.