I am trying to write something that gets all the images in a single folder and then puts them into an array so that on my web page they can randomly be up there.
Code:
<script type="text/javascript">
var myPics = new Array();
myPics[0] = "pics/cup.jpg";
myPics[1] = "pics/championship.jpg";
var randomnumber=Math.floor(Math.random()*2)
</script>
As you can see right now I am putting the image names in hard coded but when I give this to the client I would like for them to be able to just upload pictures to the folder without having to go in and change the JS
not with javascript. you will need help from a server side language. first, javascript is client-side, and second javascript don't have support for file system.
my mom is javascript, dad is javascripter, granpa is javascriptor, and my little sister is javasRidiculous. my nature language is javascript, then come spanish and english -- me
sorry, can't help with the topic. i'm not experienced with server side language. ask in sever-side development forum. i'm sure guys there will help you, or hopefully someone here will tell you. my apologies...
my mom is javascript, dad is javascripter, granpa is javascriptor, and my little sister is javasRidiculous. my nature language is javascript, then come spanish and english -- me
if you don't have an index page in a folder, but rather it shows a directory listing, you can load the folder URL in ajax, rake out the anchor tags that point to images, and build your array from that info.
in that case, you don't need any server-side code.
You can use a server side language such as PHP to generate the JavaScript. The PHP would read the list of filenames of the images from the directory and output the JavaScript code to build the array of those names.
Bookmarks