文件上传页面控制动态添加删除的代码

<%@ page language="java" pageEncoding="UTF-8"%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <title></title>
  </head>
  <script type="text/javascript">
  function more(){
  	var td = document.getElementById("more");
  	
  	var br = document.createElement("br");
  	var input = document.createElement("input");
  	var button = document.createElement("input");
  	
  	input.type="file";
  	input.value="file";
  	
  	button.type="button"
  	button.value="Remove";
  	
  	button.onclick = function(){
  		td.removeChild(br);
  		td.removeChild(input);
  		td.removeChild(button);
  	}
  	
  	td.appendChild(br);
  	td.appendChild(input);
  	td.appendChild(button);
  	
  }
  </script>
  <body>
  	<table width="80%" align="center" border="1">
  		<tr>
  			<td>
  			file:
  			</td>
  			<td id="more">
  				<input type="file" name="Files" />
  				<input type="button" value="Add More File" onclick="more()"/>
  			</td>
  		</tr>
  	</table>
  </body>
</html>

 

你可能感兴趣的:(JavaScript,html)