<!DOCTYPE html PUBLIC "
<html xmlns="
<head>
<meta http
<title>無標題文檔</title>
<link rel="stylesheet" href="tab
<script type="text/javascript" src="
<script type="text/javascript">
function createTab
{
var tabNode = doc
var tbdNode = doc
var trNode = doc
var tdNode = doc
var textNode = doc
tdNode
trNode
tbdNode
tabNode
byTag("div")[
}
function createTab()
{
var tabNode = doc
//tabNode
tabNode
var row = byName("rownum")[
var col = byName("colnum")[
for(var x=
{
var trNode = tabNode
for(var y=
{
var tdNode = trNode
tdNode
}
}
byTag("div")[
event
}
function delRow()
{
var tabNode = byId("tabid");
if(tabNode==null)
{
alert("表格不存在 ");
return;
}
var rownum = byName("delrow")[
if(rownum>
tabNode
else
{
alert("刪除的行不存在
}
}
function delCol()
{
var tabNode = byId("tabid");
if(tabNode==null)
{
alert("表格不存在 ");
return;
}
var colnum = byName("delcol")[
if(colnum>
{
for(var x=
{
tabNode
}
}
else
{
alert("刪除的列不存在");
}
}
</script>
</head>
<body>
<!
通過頁面的按鈕可以動態的創建一個表格
行
列
<input type="button" value="創建表格" onclick="createTab()" /><br />
<input type="text" name="delrow" />
<input type="button" value="刪除行" onclick="delRow()" />
<br />
<input type="text" name="delcol" />
<input type="button" value="刪除列" onclick="delCol()" />
<br />
<br />
<div>
</div>
</body>
</html>
From:http://tw.wingwit.com/Article/program/Java/JSP/201311/20196.html