|
 |
javascript thread: Directory Listing
Message #1 by KATHLEEN.M.WHALEN@c... on Fri, 23 Mar 2001 08:51:54 -0500
|
|
This is a multi-part message in MIME format.
------=_NextPart_000_0015_01C0B3CF.9D37DCE0
Content-Type: text/plain;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable
This is a sample function to (re)populate a dropdown box with the names
of XML-files in a subdirectory.
I don't explain its context (html, variable names, logic, etc.).
In runs properly using IE5.5 (within the context of my application).
The user (possibly with a browser) must allow you to access the disk.
I use a few specific features (like top.oFso and also having a first
blank position in the dropdown box),
but you should adapt it to your needs anyway.
I also advice you to get a good book (I use the wrox-book about WSH
scripting by Dino Esposito).
Good luck
Kees
function CreQuotSel()
{ oSelQuot =3D document.all("SelQuot");
var oOptions =3D oSelQuot.options;
while (oOptions.length > 0)
{ oOptions.remove(0);
}
var oOpt;
oOpt =3D document.createElement("option");
oOpt.text =3D " ";
oOpt.value =3D " ";
oOptions.add(oOpt);
if (top.oFso =3D=3D null)
{ top.oFso =3D new ActiveXObject("Scripting.FileSystemObject");
}
if (top.oFso.FolderExists(top.QuotPath + "quot"))
{ var oFiles =3D new Enumerator(top.oFso.GetFolder(top.QuotPath +
"quot").Files);
var sFileExt, sFiles =3D new Array, iFiles =3D 0;
oFiles.moveFirst();
while (!oFiles.atEnd())
{ sFileExt =3D top.oFso.GetExtensionName(oFiles.item());
if (sFileExt.toLowerCase() =3D=3D "xml")
{ sFiles[iFiles++] =3D
top.oFso.GetBaseName(oFiles.item()).toUpperCase();
}
oFiles.moveNext();
}
sFiles.sort();
if (sFiles.length > 0)
{ for (iFiles =3D 0; iFiles < sFiles.length; iFiles++)
{ oOpt =3D document.createElement("option");
oOpt.text =3D sFiles[iFiles];
oOpt.value =3D oOpt.text;
oOptions.add(oOpt);
}
}
}
oSelQuot.selectedIndex =3D 0;
}
|
|
 |