JS 操作表格2
<!doctype html public "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title> 表格操作 </title>
<meta name="Generator" content="EditPlus">
<meta name="Author" content="">
<meta name="Keywords" content="">
<meta name="Description" content="">
</head>
<body>
</body>
<script language="javascript">
//添加表格
function loadTable()
{
var tb = document.createElement("table");
var rowTitle = tb.insertRow();
var cellTitle1= rowTitle.insertCell();
var cellTitle2= rowTitle.insertCell();
cellTitle2.colSpan = 2;
cellTitle2.align = "right";
cellTitle2.innerHTML = "<input type = 'button' value= '确定' onclick='addRow(this.parentElement)'>";
cellTitle1.innerHTML = "<span>添加</span>";
loadSelect(cellTitle1);
for(var i = 0; i < 10; i++){
var row = tb.insertRow();//添加行
loadCells(row, i);
}
//设置属性
tb.id = "tb";
tb.align="center";
tb.cellPadding = 1;
tb.bgColor="#ffffee";
tb.style.borderWidth = "1px";
tb.style.borderCollapse = "collapse";
tb.style.borderStyle = "solid";
tb.rules = "ALL";//应用全部
tb.borderColor = "#000000";
document.body.appendChild(tb);
}
//添加单元格
function loadCells(rowObj,m)
{
var cell1 = rowObj.insertCell();//添加单元格
var cell2 = rowObj.insertCell();//添加第二个单元格
var cell3 = rowObj.insertCell();
cell1.innerHTML = " " + parseInt(m + 1) + " ";
cell2.innerHTML = "<input type='text' name='txt_name' value=''>";
cell3.innerHTML = "<span style='cursor:hand;' onclick='delRow(this)'> × </span>";
}
//添加select框
function loadSelect(obj)
{
var s = document.createElement("select");
s.id = "sel_count"; &n