日期:2014-05-17 浏览次数:20535 次
<script type="text/javascript"> function AddFile() { if (i <= 10) { document.getElementById("divPanel").innerHTML += "<div>照片" + i + ":<input type='file' size='30' name='File'/></div>"; i++; } } function RemoveFile() { var text = document.getElementById("divPanel").innerHTML; document.getElementById("divPanel").innerHTML = text.substr(0, text.lastIndexOf("<div>")); if (i >= 2) { i--; } else { i = 1; } } var i = 2; </script>
<table border="0" width="100%" style="position: relative;"> <tr> <td valign="top" width="100px" align="center"> <div> <span style="color: #8600FF;" onclick="AddFile()" onmousemove="javascript:this.style.cursor='pointer';"> <img src="Images/OtherImages/more.jpg" />添加</span> </div> <div> <span style="color: #8600FF;" onclick="RemoveFile()" onmousemove="javascript:this.style.cursor='pointer';"> <img src="Images/OtherImages/jian.jpg" />移除</span> </div> </td> <td> <div id="divPanel"> <div> 照片1:<input type='file' size="30" name='File' /></div> </div> </td> </tr> <tr> <td> </td> <td> <asp:ImageButton ID="ImgBtnUpLoad" ImageUrl="~/Images/OtherImages/UpLoadImage.jpg" runat="server" OnClick="ImgBtnUpLoad_Click" /> </td> </tr> </table>
<html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server"> <title>无标题页</title> <script type="text/javascript"> function AddFile() { if (i <= 10) { var div = document.createElement("div"); div.innerHTML = "照片" + i + ":<input type='file' size='30' name='File'/>"; document.getElementById("divPanel").appendChild(div); i++; } } function RemoveFile() { var text = document.getElementById("divPanel"); var divCollection = text.getElementsByTagName("div"); text.removeChild(divCollection[divCollection.length-1]) if (i >= 2) { i--; } else {