新增记录行(ecshop)

<script type="text/javascript">

function addImg(obj)

{

var src  = obj.parentNode.parentNode;

var idx  = src.rowIndex;

var tbl  = document.getElementById('gallery-table');

var row  = tbl.insertRow(idx + 1);

var cell = row.insertCell(-1);

cell.innerHTML = src.cells[0].innerHTML.replace(/(.*)(addImg)(.*)(\[)(\+)/i, "$1removeImg$3$4-");

}

 

function removeImg(obj)

{

var row = obj.parentNode.parentNode.rowIndex;

var tbl = document.getElementById('gallery-table');

tbl.deleteRow(row);

}

</script>

<table width="100%" align="center" style="display: table;" id="gallery-table">

  <tbody>

     <tr>

       <td>

          <a onclick="addImg(this)" href="javascript:;">[+]</a>

 上传文件 <input type="file" name="upfile[]" id="upfile" />

       </td>

     </tr>

  </tbody>

</table>

你可能感兴趣的:(ecshop,增加记录)