js上传

οnlοad=function(){
   var lofile = new upfile();
  }
  function upfile(aoP){
   var loThis = document.createElement("SPAN");
   var lsuniqueID = loThis.uniqueID;
   loThis.innerHTML = '<select style="width:200"></select><button οnclick="'+lsuniqueID+'.Del()">删除</button><span><span><input style="width:10" type="file" onpropertychange="'+lsuniqueID+'.Add(this)"></span></span>';
   if (aoP==null){
   document.body.appendChild(loThis);
   }else{
   aoP.appendChild(loThis);
   }
   var loSelect = loThis.children[0];
   var loFiles = loThis.children[2];
   loThis.Add = function(aoFile){
   if ((aoFile==null)||(aoFile.value=="")) return;
   var loOpts = loSelect.options;
   var lsfilename = aoFile.value.substring(aoFile.value.lastIndexOf("//")+1);
   loOpts[loOpts.length] = new Option(lsfilename,aoFile.uniqueID);
   loSelect.value = aoFile.uniqueID;
   aoFile.parentElement.style.display = "none";
   var loObj = document.createElement("span");
   loObj.innerHTML = '<input style="width:10" type="file" onpropertychange="'+lsuniqueID+'.Add(this)">';
   loFiles.insertBefore(loObj);
   }
   loThis.Del = function(){
   loEL = document.all(loSelect.value);
   if (loEL!=null){
   loEL = loEL.parentElement;
   loFiles.removeChild(loEL);
   }
   var loOpts = loSelect.options;
   if(loOpts!=null&&loOpts.length>0){
   loSel = loOpts[loSelect.selectedIndex]
   loOpts.removeChild(loSel);
   }
   }
   loThis.AddName = function(asName){
   if ((asName==null)||(asName=="")) return;
   var loOpts = loSelect.options;
   loOpts[loOpts.length] = new Option(asName,null);
   }
   loThis.getNames = function(){
   var loOpts = loSelect.options;
   var lxNames = new Array;
   for (var i=0; i<loOpts.length; i++){
   lxNames[lxNames.length] = loOpts[i].innerText;
   }
   return lxNames;
   }
   return loThis;
  }

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值