I have this code
Expand|Select|Wrap|Line Numbers
- <html>
- <head>
- <script type="text/javascript">
- var path = "C:\\Test\\Directory"
- function ShowFolderFileList()
- {
- var fso, f, fc, s, temp;
- fso = new ActiveXObject("Scripting.FileSystemObject");
- f = fso.GetFolder(path);
- fc = new Enumerator(f.files);
- s = "";
- temp = "";
- for (; !fc.atEnd(); fc.moveNext())
- {
- temp = fc.item();
- document.getElementById('filelist').options[document.getElementById('filelist').options.length] = new Option (temp, temp); // First value is the TEXT of the option, the second is the VALUE of the option.
- }
- }
- </script>
- </head>
- <body>
- <input type="button" onclick="ShowFolderFileList()" value="TEST">
- <select id="filelist">
- </select>
- </body>
- </html>
So what I tried to do is to remove the path and just keep the filename. So I added into the loop just below temp = fc.item();
Expand|Select|Wrap|Line Numbers
- s = temp.replace(/C:\\Test\\directory\\/g,"")
So the problem is that I'm referring to temp which is actually an object. And the replace function only works on strings. So my problem is that I don't know how to change it.
When I alert(temp) right after temp = fc.item(); I do get the complete path. So that's what's so weird to me.
Anyone with some thoughts?
Thanks,
Kenneth