在页面的客户端,实现一次上传多个文件总是非常麻烦,那个讨厌的file按钮总是改不了,这也许是个比较好的办法,给大家参考。删除
<form name="form" method="post" enctype="multipart/form-data" target="editpost" id="form1">
<select class="tbgen" name="selectfile" style="width:200"></select>
<button onclick="delfiletoselect()">删除</button>
<span id="affixfile">
<span><input style="width:10" name="affixs" type="file" onpropertychange="addfiletoselect(this)"></span>
</span>
</form>
<script language="javascript">
function addfiletoselect(aofile){
if ((aofile==null)||(aofile.value=="")) return;
var loopts = form.selectfile.options;
loopts[loopts.length] = new option(aofile.value,aofile.uniqueid);
aofile.parentelement.style.display = "none";
var loobj = document.createelement("span");
loobj.innerhtml = '<input style="width:10" name="affixs" type="file" onpropertychange="addfiletoselect(this)">';
affixfile.insertbefore(loobj);
}
function delfiletoselect(){
loel = document.all(form.selectfile.value);
if (loel!=null){
loel = loel.parentelement;
affixfile.removechild(loel);
}
var loopts = form.selectfile.options;
if(loopts!=null&&loopts.length>0){
losel = loopts[form.selectfile.selectedindex]
loopts.removechild(losel);
}
}
</script>