zoukankan
html css js c++ java
[Javascript]Table模版操作
<!
DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"
>
<
html
>
<
head
>
<
title
></
title
>
<
meta
name
="GENERATOR"
content
="Microsoft Visual Studio .NET 7.1"
>
<
meta
name
="vs_targetSchema"
content
="http://schemas.microsoft.com/intellisense/ie5"
>
<
script
language
="javascript"
>
var
objTable;
function
PageLoad()
{
objTable
=
document.getElementById(
"
tbNew
"
);
//
找到操作Table
}
function
tdvalue()
{
var
objTempRow
=
objTable.rows[
0
];
//
找到Table的模版行
var
objNewRow
=
objTable.insertRow( objTable.rows.length );
//
在Table的末尾新增一行
objNewRow.id
=
objTable.rows.length
-
1
;
//
以模版行建立新行内容
for
(
var
i
=
0
; i
<
objTempRow.cells.length ; i
++
)
{
var
objNewCell
=
objNewRow.insertCell( i );
objNewCell.innerHTML
=
objTempRow.cells[i].innerHTML;
}
}
function
DeleteTableRow()
{
if
( objTable.rows.length
-
1
>
0
)
{
objTable.deleteRow(objTable.rows.length
-
1
);
}
else
{
//
}
}
window.onload
=
PageLoad;
</
script
>
</
head
>
<
body
>
<
form
id
="Form1"
name
="Form1"
>
<
input
id
="btnInsert"
name
="btnInsert"
type
="button"
onclick
="tdvalue()"
value
="添加新行"
/>
<
input
id
="btnDelete"
name
="btnDelete"
type
="button"
onclick
="DeleteTableRow()"
value
="删除末行"
/>
</
form
>
<
TABLE
id
="tbNew"
cellSpacing
="1"
cellPadding
="1"
width
="100%"
border
="1"
>
<!--
此处为模版行
-->
<
TR
>
<
TD
><
input
id
="txtData_1"
name
="txtData_1"
type
="text"
value
=""
/></
TD
>
<
TD
><
input
id
="txtData_2"
name
="txtData_2"
type
="text"
value
=""
/></
TD
>
<
TD
><
input
id
="txtData_3"
name
="txtData_3"
type
="text"
value
=""
/></
TD
>
</
TR
>
<!--
------------
-->
</
TABLE
>
</
body
>
</
html
>
查看全文
相关阅读:
ASC2 做题记录
ASC1 做题记录
Codeforces #676 (div 2) 做题记录
Codeforces #639 (div 1) 做题记录
Atcoder Beginner Contest 160 做题记录
CodeCraft-20 (div 2) 做题记录
Codeforces 1242C
Codeforces 1102F
codeforces 732F
codeforces 405E
原文地址:https://www.cnblogs.com/HD/p/153192.html
最新文章
okhttp发送post请求
【转载】@staticmethod怎么用? --python
待更-Docker容器和镜像的介绍和具体用法实操
待更-Docker实战(案例操作步骤)
待更-Docker容器数据卷和Docker File介绍以及使用实操
Docker简介
Docker安装教程(基于虚拟机中的Centos7)
Linux top命令 查看服务器资源占用情况
IDE-VScode 安装与简单使用教程(Windows+python)
ubuntu笔记
热门文章
2019/12/22 TZOJ
Amber
2019/11/09 TZOJ
2019/10/27 TZOJ
2019/11/02 TZOJ
延时计算
2019/10/26 TZOJ
2019/10/13 TZOJ
SAT算法
二叉树
Copyright © 2011-2022 走看看