动态添加附件上传按钮

 <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 = '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<INPUT type="file" size="50" NAME="File">&nbsp;&nbsp;<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>

转载于:https://www.cnblogs.com/starstarfire/archive/2006/06/11/423330.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值