博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
js添加删除行
阅读量:4318 次
发布时间:2019-06-06

本文共 2164 字,大约阅读时间需要 7 分钟。

<html xmlns="http://www.w3.org/1999/xhtml"> <head> <title></title> <script type="text/javascript"> function insertRow(tbIndex) { var objRow = Binddata.insertRow(tbIndex); var objCel = objRow.insertCell(0); objCel.style.display = "none"; objCel.innerText = tbIndex; var objCel = objRow.insertCell(1); objCel.innerText = document.getElementById("myCell1").value; var objCel = objRow.insertCell(2); objCel.innerText = document.getElementById("myCell2").value; var objCel = objRow.insertCell(3); objCel.innerText = document.getElementById("myCell3").value; var objCel = objRow.insertCell(4); objCel.innerText = document.getElementById("myCell4").value; var objCel = objRow.insertCell(5); objCel.innerHTML = "<a href='javascript:void(0)' οnclick='javascript:del();'>删除</a>"; // objRow.attachEvent("onclick", getIndex); objRow.style.background = "pink"; } function del() { inRowIndex = event.srcElement.parentNode.parentNode.rowIndex; Binddata.deleteRow(inRowIndex); } // function getIndex() { // intRowIndex = event.srcElement.parentNode.parentNode.rowIndex; // alert("getIndex:" + intRowIndex); // pos.innerText = intRowIndex; // return intRowIndex; // } </script> </head> <body> <div id="getTable" οnlοad="pos.innerText=intRowIndex;"> <table> <!--<tr> <td colspan="6"> 当前位置:<span id="pos"></span> </td> </tr>--> <tr> <td colspan="6"> <table width="100%" id="Binddata"> <thead id="thead"> <tr> <th> ID </th> <th> 配件名称 </th> <th> 使用数量 </th> <th> 价格 </th> <th> 单位 </th> <th> 操作 </th> </tr> </thead> <tbody id="tbody"> <%=BindTable()%> </tbody> </table> </td> </tr> <tr> <td align="center"> 配件名称:<input type="text" id="myCell1" name="myCell1" value="CGI" /> </td> <td align="center"> 使用数量:<input type="text" id="myCell2" name="myCell2" value="CGI" /> </td> <td align="center"> 价格:<input type="text" id="myCell3" name="myCell3" value="CGI" /> </td> <td align="center"> 单位:<input type="text" id="myCell4" name="myCell4" value="CGI" /> </td> <td colspan="2" align="center"> <input type="button" name="Submit" value="添加" οnclick="insertRow(Binddata.rows.length)" /> </td> </tr> </table> </div> </body> </html>
 

转载于:https://www.cnblogs.com/xiacy/archive/2011/09/30/2485708.html

你可能感兴趣的文章
高性能HTTP加速器Varnish(概念篇)
查看>>
Linux 如何写makefile文件
查看>>
flutter_webview_plugin 无法加载网页的异常处理
查看>>
bloc控制读写文件
查看>>
微信小程序
查看>>
洛谷 P1059 明明的随机数
查看>>
window自动任务实现数据库定时备份
查看>>
Windows 7 Ultimate(旗舰版)SP1 32/64位官方原版下载(2011年5月12日更新版)
查看>>
javascript操作cookie
查看>>
深入理解HTTP协议(转)
查看>>
NHibernate讲解
查看>>
Android开发环境搭建(原创)
查看>>
js / jquery 获取和设置 FCK Editor 的值
查看>>
剑指offer-二叉树中和为某一值的路径
查看>>
grid - 网格项目跨行或跨列
查看>>
2019年2月
查看>>
STL库的应用
查看>>
spark算子
查看>>
(转)Linux服务器SNMP常用OID
查看>>
USB各种模式 解释
查看>>