效果如下:
AddFIles
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<TITLE> New Document </TITLE>
<META NAME="Generator" CONTENT="EditPlus">
<META NAME="Author" CONTENT="">
<META NAME="Keywords" CONTENT="">
<META NAME="Description" CONTENT="">
<script language=javascript>
var filecount=1;
function addfile()
{
var filediv = document.getElementById("files");
var fileitemdiv = document.createElement("div");
filecount++;
var content = "<input type=file name=fileupload"+
filecount + "> <a href='javascript:removefile("+
filecount + ");'>remove</a>"
fileitemdiv.id = "fileitemdiv"+filecount;
fileitemdiv.innerHTML = content;
filediv.appendChild(fileitemdiv);
}
function removefile(fileIndex)
{
var filediv = document.getElementById("files");
var fileitemdiv = document.getElementById("fileitemdiv"+fileIndex);
filediv.removeChild(fileitemdiv);
}
</script>
</HEAD>
<BODY>
<div id=files>
<input type=file name=fileupload1 /><br/>
</div>
<input type=button value="add file" onclick="addfile();">
</BODY>
</HTML>