动态表格,通过按钮增加行,删除时删除选择的checkbox那一行
来源:互联网 发布:apache重启不了 编辑:程序博客网 时间:2024/05/19 05:37
<script>
//给table增加一行
function addTableRow() {
var table1 = document.getElementById('table1');
var cloneTab = document.getElementById('table2');
//alert(cloneTab.firstChild.firstChild.innerHTML);
//alert(cloneTab.firstChild.firstChild.cloneNode(true).innerHTML);
table1.firstChild.appendChild(cloneTab.firstChild.firstChild.cloneNode(true));
var v= table1.firstChild.childNodes;
var len = v.length;
for(var i=1;i<len;i++){
v[i].childNodes[0].firstChild.id=i;//给第一个单元格id赋值
}
}
//给table删除一行
function delTableRow(){
var table1 = document.getElementById('table1');
var isChecked = document.getElementsByName('isChecked');
var len = isChecked.length;
for(var i=len-1;i>=0;i--){
if(isChecked[i].checked==true){
table1.firstChild.removeChild(isChecked[i].parentNode.parentNode);
//alert(isChecked[i].id);
//alert(isChecked[i].parentNode.parentNode.innerHTML);
}
}
}
</script>
《
<!--显示table-->
<table border="0" cellpadding="0" cellspacing="0" class="datalist" id="table1">
<tr>
<th width="38" nowrap="nowrap" style="width: 5%">0</th>
<th width="38" nowrap="nowrap" >00</th>
<th width="79" nowrap="nowrap" scope="col">1</th>
<th width="70" nowrap="nowrap" scope="col">2</th>
<th width="69" nowrap="nowrap" scope="col">3</th>
<th width="66" nowrap="nowrap" scope="col">4</th>
<th width="94" nowrap="nowrap" scope="col">5</th>
<th width="107" nowrap="nowrap" scope="col">6</th>
</tr>
</table>
<!--控制table的按钮-->
<table>
<tr align="center">
<td colspan="10">
<input type="button" value="增加" onclick= "addTableRow();"/>
<input type="button" value="删除" onclick="delTableRow();"/>
</td>
</tr>
</table>
<!--模板table也叫做clone table style = "display:none"-->
<table id='table2' style="display: none">
<tr>
<th><input type="checkbox" name="isChecked" /><input type="hidden" size="6" value=""/></th>
<th width="38" nowrap="nowrap" style="width: 5%"><input type="text" size="16" maxlength="50" value=""/></th>
<th width="79" nowrap="nowrap" scope="col"><input type="text" size="16" maxlength="50" value=""/></th>
<th width="70" nowrap="nowrap" scope="col"><input type="text" size="6" maxlength="10" value=""/></th>
<th width="69" nowrap="nowrap" scope="col">
<select size="1">
<option value="">请选择...</option>
<option value="1">1</option>
<option value="2">1</option>
</select>
</th>
<td width="100" nowrap="nowrap" scope="col"><input type="text" class="date150"/></td>
<th width="94" nowrap="nowrap" scope="col"><input type="text" size="16" maxlength="50" value=""/></th>
<th width="71" nowrap="nowrap" scope="col"><input type="text" size="16" maxlength="50" value=""/></th>
</tr>
</table>
- 动态表格,通过按钮增加行,删除时删除选择的checkbox那一行
- 动态表格,通过点击按钮增加或者删除一行表格!
- 表格动态增加一行和删除一行
- JS 动态给表格增加/删除一行
- HTML表格动态增加一行/删除/修改
- jQuery动态增加表格一行和删除一行
- jQuery动态增加表格一行和删除一行
- 动态增加删除表格行
- JQ点击按钮动态克隆一行表格以及删除表格
- javascript动态添加表格,通过checkbox动态删除表格
- 表格动态增加删除
- 点击按钮实现表格动态添加或删除一行
- 在可编辑表格EditorGrid中,我选择一行已输入的数据,点击删除按钮,该行数据将被删除,然后当我点击表单提交按钮时,已经被删除的那一行数据仍然被插入数据库中
- 表格动态添加删除一行
- html表格的动态增加与删除
- 表格行的动态增加和删除的实现
- 表格动态增加行删除行
- 动态增加,删除表格中的行
- jQuery中添加自定义或函数方法
- ExtJS 3.1.0中Ext.data.Store关于baseParams的BUG修正
- c++学习--C/C++常用函数
- WS_EX_TOOLWINDOW 属性的陷阱
- TI OMAP35X系统为什么需要x-load
- 动态表格,通过按钮增加行,删除时删除选择的checkbox那一行
- Domino错误信息的详细分析
- Linux下的多线程编程
- 配置 SQL SERVER2008 数据库邮件 功能
- 在python 中调用Dll
- 怎么退出整个框架
- 动态表格,通过点击按钮增加或者删除一行表格!
- 通过VBS获取磁盘剩余空间
- pig安装及问题