JScript参考手册里有呀.
------------------------
<body>
<table>
<tr><td colspan=2 align="left"><select id="fsDrivers" onchange="ChangeDrive(this)"><option>--请选择驱动器--</option></select></td></tr>
<tr><td valign="top"><select id="fsFolders"><option>---请选择目录---</option></select></td><td valign="top"><select size=20 id="fsFiles" style="width:200px;"></select></td></tr>
</table>
</body>
<script>
function $(id)
{
return (id.constructor == String) ? document.getElementById(id) : id;
}
function ChangeDrive(t)
{
var index = t.selectedIndex;
if (index == 0) {
var temp = document.createElement('OPTION');
temp.innerText = '---请选择目录---';
var o = $('fsFolders');
o.innerHTML = '';
o.appendChild(temp);
} else {
var tmp = t.options[index].value + '\\\\';
var a = ShowFolderList(tmp);
var o = $('fsFolders');
o.innerHTML = '';
for(var i=0; i<a.length; i++) {
var op = document.createElement('OPTION');
op.value = a[i];
op.innerText = a[i];
o.appendChild(op);
} }
}
function ShowFolderList(folderspec)
{
var fso, f, fc, a;
fso = new ActiveXObject("Scripting.FileSystemObject");
f = fso.GetFolder(folderspec);
fc = new Enumerator(f.SubFolders);
a = new Array;
for (; !fc.atEnd(); fc.moveNext())
{
a[a.length] = fc.item();
}
return(a);
}
function getDrives()
{
var fso, a, n, e, x;
fso = new ActiveXObject("Scripting.FileSystemObject");
e = new Enumerator(fso.Drives);
a = new Array;
for (; !e.atEnd(); e.moveNext())
{
x = e.item();
a[a.length] = x.DriveLetter;
}
return(a);
}
var a = getDrives();
var o = $('fsDrivers');
for(var i=0; i<a.length; i++) {
var op = document.createElement('OPTION');
op.value = a[i] + ':';
op.innerText = a[i] + ':';
o.appendChild(op);
}</script>
------------------------
<body>
<table>
<tr><td colspan=2 align="left"><select id="fsDrivers" onchange="ChangeDrive(this)"><option>--请选择驱动器--</option></select></td></tr>
<tr><td valign="top"><select id="fsFolders"><option>---请选择目录---</option></select></td><td valign="top"><select size=20 id="fsFiles" style="width:200px;"></select></td></tr>
</table>
</body>
<script>
function $(id)
{
return (id.constructor == String) ? document.getElementById(id) : id;
}
function ChangeDrive(t)
{
var index = t.selectedIndex;
if (index == 0) {
var temp = document.createElement('OPTION');
temp.innerText = '---请选择目录---';
var o = $('fsFolders');
o.innerHTML = '';
o.appendChild(temp);
} else {
var tmp = t.options[index].value + '\\\\';
var a = ShowFolderList(tmp);
var o = $('fsFolders');
o.innerHTML = '';
for(var i=0; i<a.length; i++) {
var op = document.createElement('OPTION');
op.value = a[i];
op.innerText = a[i];
o.appendChild(op);
} }
}
function ShowFolderList(folderspec)
{
var fso, f, fc, a;
fso = new ActiveXObject("Scripting.FileSystemObject");
f = fso.GetFolder(folderspec);
fc = new Enumerator(f.SubFolders);
a = new Array;
for (; !fc.atEnd(); fc.moveNext())
{
a[a.length] = fc.item();
}
return(a);
}
function getDrives()
{
var fso, a, n, e, x;
fso = new ActiveXObject("Scripting.FileSystemObject");
e = new Enumerator(fso.Drives);
a = new Array;
for (; !e.atEnd(); e.moveNext())
{
x = e.item();
a[a.length] = x.DriveLetter;
}
return(a);
}
var a = getDrives();
var o = $('fsDrivers');
for(var i=0; i<a.length; i++) {
var op = document.createElement('OPTION');
op.value = a[i] + ':';
op.innerText = a[i] + ':';
o.appendChild(op);
}</script>
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货