iPixel Posted February 2, 2011 Share Posted February 2, 2011 So i pass 2 variables to a js function. Image Source and the Image Name. I want to use the image name to know what image i should show to the user first but i need to use the image source in order to look into a specified directory, find all the files that exist there and place all the filenames into a javascript array. function showgallery(imgsrc,img) { // Do some fancy stuff to show Large Photo here... (this part i can do) // Get Directory listed and placed into array so that i can do previous / next photo changing. --- THIS PART I NEED HELP WITH } Thanks Much! Link to comment https://forums.phpfreaks.com/topic/226414-listing-directory-into-a-javascript-array-help-pls/ Share on other sites More sharing options...
.josh Posted February 2, 2011 Share Posted February 2, 2011 You cannot do this with javascript. You have to use server-side script to get a list of files in directory on server and output it to the client (in the form of a js array or whatever). You can do it on page load or use ajax to make a request to server-side script to get a listing and return results. Link to comment https://forums.phpfreaks.com/topic/226414-listing-directory-into-a-javascript-array-help-pls/#findComment-1168650 Share on other sites More sharing options...
iPixel Posted February 2, 2011 Author Share Posted February 2, 2011 that makes sense, clearly im an idiot i completely forgot js is client side. Thanks! AJAX is a great alternative Link to comment https://forums.phpfreaks.com/topic/226414-listing-directory-into-a-javascript-array-help-pls/#findComment-1168651 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.