日期:2014-05-17 浏览次数:20461 次
<script language="JavaScript" type="text/javascript"> var index = 1; function addFile(){ var fartherID = "addedFile" + index; var divToAdd = document.createElement("div"); divToAdd.id = fartherID; var str = '<INPUT style="width:284px;" type="file" contentEditable="false" id="subFile' + index + '" name="subFilename' + index + '" /> ' + '<a fartherID="' +fartherID +'" onclick="removeFileChild(this)" style="cursor: hand;">删除</a>'; divToAdd.innerHTML = str; var fartherObject = document.getElementById('btAddFile'); fartherObject.appendChild(divToAdd); index++; } </script> <form id="form1" runat="server"> <div> <asp:FileUpload ID="SubFile0" runat="server" Width="284px" contenteditable="false" /> </div> <div id="btAddFile"> </div> <div> <a href="javascript:addFile()">添加附件</a> </div> </form>
------解决方案--------------------
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>jsDoc中文网-locale photo</title> <script> function AddMoreRow() { var oRow=event.srcElement.parentNode.parentNode; var oTable=oRow.parentNode.parentNode; oNewRow=oTable.insertRow(); for(i=0;i<oRow.cells.length;i++) { oNewRow.insertCell().innerHTML=oRow.cells[i].innerHTML; } oRow.all("DelBtn").disabled=false; oNewRow.all("DelBtn").disabled=false; } function DeleteMoreRow() { var oRow=event.srcElement.parentNode.parentNode; var oTable=oRow.parentNode.parentNode; if(oTable.rows.length>1) { oTable.deleteRow(oRow.rowIndex); if(oTable.rows.length==1) { oTable.all("DelBtn").disabled=true; } } } function DisabledKeyInput() { if(event.keyCode!=8&&event.keyCode!=46) { event.returnValue=false; } } </script> </head> <body topmargin="10"> <form method="post" enctype="multipart/form-data"> <table><th>批量上传</th></table> <table> <tr> <td nowrap="nowrap">名称*</td> <td><input type