用XML+FSO+JS实现服务器端文件的选择效果(2)


 var ooRoot=oXMLDoc.root;
return ooRoot;
  }
//当选中一个文件时,把这个值返回给文本框
function addfile(txt)
{
document.all.filename.value=txt;
}

var first=1;//定义一个全局变量

function userlist(folders,ti)//列出所选框
{document.f1.folder.value=folders;
filebox.document.body.innerHTML="正在加载文件,请稍侯...";
  var strshow="";
 var timeoutid=null;
 var newfolder="";
 var arrfolder=new Array();
 var arrff=new Array();
 var blankstr="";
 var oItem;
 //确定历史状态
 hisi+=ti;
 arrhistory[hisi]=folders;
 if (hisi==0)
 {
 arrow.innerHTML="<img src=\"images/grayarrow.gif\">";
 }
 else
 {
 arrow.innerHTML="<img src=\"images/arrow.gif\" border=0 style=\"cursor:hand\" onclick=\"userlist('"+arrhistory[hisi-1]+"',-1)\" onmouseover=\"this.src='images/arrow_over.gif'\" onmouseout=\"this.src='images/arrow.gif'\">";
 }
 //确定当前的文件夹
 if (document.f1.folder.value=="")
 {
 folderid.innerHTML="<img src=\"images/grayfolder.gif\">"
 }
 else
 {newsfolder=checkfolder(document.f1.folder.value)
 folderid.innerHTML="<img src=\"images/folder.gif\" border=0 style=\"cursor:hand\" onclick=\"userlist('"+newsfolder+"',1)\" onmouseover=\"this.src='images/folder_over.gif'\" onmouseout=\"this.src='images/folder.gif'\">"
 }
 //给下拉框赋值
 document.all.select.options.length=0;
 newfolder=folders;
 folderstr=""
 var _obj=document.all.select;
 var _o=document.createElement("Option");
 _o.text="选择文件夹";
 _o.value="";
 _obj.add(_o);
 if (newfolder!="")
 {arrfolder=newfolder.split("/")
  for(var i=0;i<arrfolder.length-1;i++)
  {blankstr+="  ";
  folderstr+=arrfolder[i]+"/";
  _o=document.createElement("Option");
  _o.text=blankstr+arrfolder[i];
  _o.value=folderstr;
  _obj.add(_o);

  }
 }
document.all.select.options[document.all.select.options.length-1].selected=true;
 url="getfolder.asp.gl?folder="+folders;
 oRoot=getuserlist(url)
  strshow="<table class=file cellspacing=0 cellpadding=0>";
 len=oRoot.children.length;
 if (len==1)
 {oItem = oRoot.children.item(0);
 if(oItem.children.item(0).text=="empty")
 strshow="没有文件和文件夹了";
 else
 {
 if(oItem.children.item(0).text=="folder")
   {
   strshow+="<tr><td><A href=\"javascript:parent.userlist('"+folders+oItem.children.item(1).text+"/"+"',1)\"><img src=\"images/mediafolder.gif\" border=0 >"+oItem.children.item(1).text+"</A></td></tr>";
   }

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:http://www.heiqu.com/3678.html