<SCRIPT LANGUAGE=javascript>
function delCol() {
try {
var Elm = event.srcElement;
while(Elm && Elm.tagName != "TR") {
Elm = Elm.parentElement;
}
if(Elm.parentElement.rows.length <= 1) {
alert("无法删除!");
return;
}
Elm.parentElement.deleteRow(Elm.rowIndex);
} catch(e) {
alert("Err 5001:\r\n" + e);
}
}
function addCol(id) {
try {
var oTable = document.getElementById(id);
if(oTable.tagName != "TABLE")
  alert("Err 5002");
var oList = oTable.children;
var oTBODY;
for(var i=0;i<oList.length;i++) {
if(oList[i].tagName == "TBODY") {
oTBODY = oList[i];
break;
}
}
var oTR = oTBODY.lastChild;
var newTR = oTR.cloneNode(true);
addId(newTR);
oTBODY.insertAdjacentElement("beforeEnd",newTR);
} catch(e) {
alert("Err 5002:\r\n" + e);
}
}
function addId(node) {
try {
if(!node.hasChildNodes()) {
var prefix = node.getAttribute("id").split("_")[0];
var postfix = node.getAttribute("id").split("_")[1];
postfix = parseInt(postfix) + 1;
node.setAttribute("id",prefix + "_" + postfix);
node.setAttribute("value","");
return;
}
} catch(e) {}
try {
var oList = node.childNodes;
for(var i=0;i<oList.length;i++) {
addId(oList[i]);
}
} catch(e) {
alert("Err 5003:\r\n" + e);
}
}
</SCRIPT>
<table width="100%" border="0" align="center" cellpadding="3" cellspacing="1" bordercolor="#000000" class="tableprintable" id="t1">
                <tr align="center" class="tdbg0"> 
                   <td class="tdbg0"><button class="button" onClick="delCol()"> 
                    删除</button></td>
                </tr>
              </table>
              <button class="button" onClick="addCol('t1')">添加一行</button>
            </td>
          </tr>
        </table>

解决方案 »

  1.   

    http://expert.csdn.net/Expert/topic/1462/1462881.xml?temp=6.066531E-02
      

  2.   

    <SCRIPT>
    function fnAddRow(oTable){
       var oLastRow = oTable.rows[oTable.rows.length-1]
       var oCloneNode = oLastRow.cloneNode(true);
       oLastRow.parentElement.insertAdjacentElement("beforeEnd", oCloneNode);
    }
    </SCRIPT><TABLE id=tbl1 WIDTH=75% BORDER=1 CELLSPACING=1 CELLPADDING=1>
    <TR>
    <TD>a</TD>
    <TD>a</TD>
    <TD>a</TD>
    </TR>
    <TR>
    <TD>a</TD>
    <TD>a</TD>
    <TD>a</TD>
    </TR>
    <TR>
    <TD>a</TD>
    <TD>a</TD>
    <TD>a</TD>
    </TR>
    </TABLE><INPUT
       TYPE="button"
       VALUE="Add Row"
       onclick="fnAddRow(document.all.tbl1)"
    >
      

  3.   

    http://expert.csdn.net/Expert/topic/983/983335.xml?temp=.5647852
      

  4.   

    抄的:
    <SCRIPT LANGUAGE="JScript"> //动态增加表格的行和列 
    function rm(){
    if (mytab.rows.length>1){
    mytab.deleteRow(mytab.rows.length-1)
    }
    }
    function add(){
    r=mytab.insertRow();
    r.insertCell().innerText=k;
    r.insertCell().innerText="A";
    r.insertCell().innerText="B";
    r.insertCell().innerText="C";
    r.insertCell().innerText="D";
    //r.ondblclick()="this.style.color='red'";
    } </SCRIPT>