I have an image loading function in a js file.
It loads images from 1.jpg to a specified number (let's say 20).
What I would like to do instead of specifying a number, is find out how many images are in the folder and then use that as the specified number.
I know it is possible using GLOB in PHP, but AFAIK you can't use PHP in a js file?
function loadpics(url){
var txt,i,j;
j=20
//j=count(glob("images/" + url + "/*",GLOB_BRACE)); PHP file count here.
txt= "<span id=\"lar\">«</span><img id=\"main-img\" src=\"images/" + url + "/1.jpg\"/><span id=\"rar\">»</span><div id=\"scroller\">";
for (i=1;i<j;i++)
{
txt += "<img src=\"images/" + url + "/t/" + i + ".jpg\"/>";
}
document.getElementById("sidebar-b").innerHTML=txt + "</div>";
}
So how can I get the number of files from the url I pass to my loading picture function?
Or is there a better way?