对象化JS之----文件上传客户端控制脚本
2003-01-23 09:46
751 查看
<SCRIPT LANGUAGE=javascript>
onload=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 onclick="'+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;
}
</SCRIPT>
onload=function(){
var lofile = new upfile();
}
function upfile(aoP){
var loThis = document.createElement("SPAN");
var lsuniqueID = loThis.uniqueID;
loThis.innerHTML = '删除';
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 = '';
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
onload=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 onclick="'+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;
}
</SCRIPT>
onload=function(){
var lofile = new upfile();
}
function upfile(aoP){
var loThis = document.createElement("SPAN");
var lsuniqueID = loThis.uniqueID;
loThis.innerHTML = '删除';
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 = '';
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
相关文章推荐
- js控制上传文件大小
- Python脚本控制的WebDriver 常用操作 <二十六> 上传文件
- html5中的input(type="file")的multiple属性,实现多文件上传,并用js控制文件大小,数量
- js上传文件控制
- js用FileSystemObject 对象实现文件控制
- 脚本控制上传文件大小
- js控制上传文件的文本框,不能输入内容,贴粘,及输入法切换.
- 客户端js判断文件类型和文件大小即限制上传大小
- JS控制FileUpload的上传文件类型实例代码
- input file 文件上传,js控制上传文件的大小和格式
- 客户端上传文件时,用Javascript(Js)取得文件名及文件后缀(File,图片)
- vuejs使用FormData对象,ajax上传图片文件
- js提交form表单 - input file 文件上传控制上传文件的大小和格式
- JS控制上传文件大小
- FTP自动上传文件脚本(客户端 DOS)
- MVC文件图片ajax上传轻量级解决方案,使用客户端JSAjaxFileUploader插件01-单文件上传
- HTML5文件上传器,纯脚本无插件的客户端文件上传器
- 使用JS实现在客户端判断上传文件大小
- 客户端js校验文件上传格式与文件大小
- SharePoint 2010开发实例精选——通过客户端对象模型上传下载文件