Menulist Javascript
any开发者_C百科 one can tell how can i load list of files from a folder into a Menulist using JavaScript Arrays.
I beleave it is possible only using ActiveX Object, which is supported by IE only. Here You can find some tutorials: http://www.daniweb.com/web-development/javascript-dhtml-ajax/threads/144152 .
If You are making something for internal use, than You might consider using ActiveX Object. Otherwise, not possible with JS, unfortunately - use server-side languages.\
Example of listing all files in a directory with Java:
import java.io.File;
public class ListFiles {
public static void main(String[] args) {
// Directory path here
String path = ".";
String files;
File folder = new File(path);
File[] listOfFiles = folder.listFiles();
for (int i = 0; i < listOfFiles.length; i++) {
if (listOfFiles[i].isFile()) {
files = listOfFiles[i].getName();
System.out.println(files);
}
}
}
}
You can then output the files to the webpage with what ever method You are using.
精彩评论