动态添加、删除上传控件
<body>
<form id="form1" runat="server">
<table id="tb1" border="0">
<tr><td><a href="#" onclick="return addFj()">添加附件</a></td></tr>
</table>
<input type="hidden" name="fjCnt" value="1" />
</form>
</body>
</html>
<script type="text/javascript" language="javascript">
function addFj()
{
var oTb = document.getElementById("tb1");
var oTr = oTb.insertRow(0);
var name = "thefilename"+document.form1.fjCnt.value;
document.form1.fjCnt.value=parseInt(document.form1.fjCnt.value)+1;
oTr.insertCell(0).innerHTML = "<input id='file' name='"+name+"' type=file style='width:400px;'> <input type=button onclick='return delFj(this)' value='删除'>"
return false;
}
function delFj(obj)
{
obj.parentElement.parentElement.removeNode(true);
return false;
}
</script>
<form id="form1" runat="server">
<table id="tb1" border="0">
<tr><td><a href="#" onclick="return addFj()">添加附件</a></td></tr>
</table>
<input type="hidden" name="fjCnt" value="1" />
</form>
</body>
</html>
<script type="text/javascript" language="javascript">
function addFj()
{
var oTb = document.getElementById("tb1");
var oTr = oTb.insertRow(0);
var name = "thefilename"+document.form1.fjCnt.value;
document.form1.fjCnt.value=parseInt(document.form1.fjCnt.value)+1;
oTr.insertCell(0).innerHTML = "<input id='file' name='"+name+"' type=file style='width:400px;'> <input type=button onclick='return delFj(this)' value='删除'>"
return false;
}
function delFj(obj)
{
obj.parentElement.parentElement.removeNode(true);
return false;
}
</script>