方法一:
<html>
<head>
<meta http-equiv="content-type" content="text/html">
<title>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="text" name="Name" size="15" maxlength="50"></td>
<td nowrap="nowrap">文件路径*</td>
<td><input type="file" name="FilePath" size="15" onKeyDown="DisabledKeyInput()" /></td>
<td nowrap="nowrap">说明*</td>
<td><input type="text" name="Description" size="45"><input type="button" value="增加" onclick="AddMoreRow()"></td>
<td nowrap="nowrap">
<input type="button" id="DelBtn" value="删除" disabled="disabled" onClick="DeleteMoreRow()">
</td>
</tr>
</table>
<table>
<tr align="center">
<td align="center">
<input type="submit" value="保存"> <input type="reset" value="取消"></td>
</tr>
</table>
</form>
</body>
</html>
方法二:
<style>
*{font-size:12px;cursor:default}
.hand{cursor:hand;cursor:pointer}
</style>
<body>
<form name=fm1>
<div id=bxAttList>
<div id=bxAtt onmouseover="$('bxAtt1').style.textDecoration='underline'" onmouseout="$('bxAtt1').style.textDecoration=''" style=float:left;width:60>
<span id=bxAtt1 style='position:absolute;padding-top:3;cursor:hand;font-family:宋体'>@添加附件</span>
<span id=bxAtt2 onmouseover=this.scrollLeft=100 style=position:absolute;width:60;overflow:hidden;filter:alpha(opacity=0);-moz-opacity:0></span>
</div>
</div>
</form>
</body>
<script>
file_create()
function file_create(){
$("bxAtt2").innerHTML="<input onchange=file_change(this) hidefocus type=file name=file1 size=1 class=hand>"
}
function file_change(tx){
var sName,o
sName=tx.value.replace(////g,"/").replace(/(.*//)(.*)/,"$2")
o=document.createElement("nobr")
o.style.cssText="float:left;margin-right:6;padding-top:3;color:darkgreen"
o.innerHTML="□"+sName+"<font onclick=$('bxAttList').removeChild(this.parentNode);file_repos() class=hand style=color:red;font-weight:bold>"+unescape("×")+"</font>"
tx.style.display="none"
o.appendChild(tx)
$("bxAttList").insertBefore(o,$("bxAtt"))
file_repos()
file_create()
}
function file_repos(){
$("bxAttList").appendChild($("bxAtt"))
}
function $(obj){
return typeof(obj)=="object"?obj:document.getElementById(obj)
}
</script>