时间: 2021-07-31 作者:daque
在页面包车型的士存户端,实行一次上传多个文献总利害常烦恼,谁人腻烦的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>