<table id="tbAccessory" height="0" cellSpacing="0" cellPadding="0" width="663" align="center"
bgColor="#ccccff" border="0">
<tr>
<td>
<p id="MyFile"></p>
</td>
</tr>
</table>
<script>
var iFileCount=0;
function add()
{
iFileCount=iFileCount+1;
var addCell = new Array();
if(iFileCount<4)
{
if(iFileCount==1)
{
document.all.btAccessory.value='继续粘贴附件';
}
if(iFileCount==3)
document.all.btAccessory.value='粘贴附件';
var str = ' <INPUT type="file" size="50" NAME="File"> <input type=button name=del value=删除 οnclick=delFile('+iFileCount+')><br>';
addCell[0]=str;
runRowInsert(tbAccessory, addCell);
//document.getElementById('MyFile').insertAdjacentHTML("beforeEnd",str);
//document.getElementById('tbAccessory').insertAdjacentHTML("beforeEnd",str);
}
}
function delFile(index)
{
if(iFileCount==1 && index>0)
tbAccessory.deleteRow(1);
else
tbAccessory.deleteRow(index);
iFileCount=iFileCount-1;
//alert(iFileCount.toString());
}
function runRowInsert(TableHandle, GetCells, RowIndex){
var oRow = null;
var oCel = null;
if (typeof(GetCells) != 'object' || GetCells.length == 0){
alert('错误信息:\n* 没有任何数据需添加!');
}else{
if (typeof(RowIndex) != 'number'|| RowIndex < 0){
oRow = TableHandle.insertRow();
}else{
if (RowIndex < TableHandle.length){
oRow = TableHandle.insertRow(RowIndex);
}else{
oRow = TableHandle.insertRow();
}
}
for (var i = 0; i < GetCells.length; i++){
oCel = oRow.insertCell();
oCel.innerHTML = GetCells[i];
}
}
return oRow;
}
</script>