http://fason.nease.net/zhuanti/table/sample1.htm

解决方案 »

  1.   

    <HTML>
    <HEAD>
    <META NAME="GENERATOR" Content="Microsoft Visual Studio 6.0">
    <TITLE></TITLE>
    <SCRIPT ID=clientEventHandlersJS LANGUAGE=javascript>
    <!--function button1_onclick() {
    tb.insertRow();
    }//-->
    </SCRIPT>
    </HEAD>
    <BODY><P>
    <TABLE cellSpacing=1 cellPadding=1 width="75%" border=1 id=tb>
      
      <TR>
        <TD>&nbsp;</TD>
        <TD>&nbsp;</TD>
        <TD>&nbsp;</TD></TR>
      <TR>
        <TD>&nbsp;</TD>
        <TD>&nbsp;</TD>
        <TD>&nbsp;</TD></TR>
      <TR>
        <TD>&nbsp;</TD>
        <TD>&nbsp;</TD>
        <TD>&nbsp;</TD></TR></TABLE></P><INPUT id=button1 type=button value=Button name=button1 LANGUAGE=javascript onclick="return button1_onclick()"></BODY>
    </HTML>
      

  2.   

    function aainsert()
    {
    table = document.getElementById(tableID);
    myNewRow =table.insertRow(table.rows.length);
    i=i+1;
    myNewCell = myNewRow.insertCell(0);
    myNewCell.innerHTML = "<input type='text' name=aa"+i+" value=aa"+i+">";
    i=i+1;
    myNewCell = myNewRow.insertCell(1);
    myNewCell.innerHTML = "<input type='text' name=aa"+i+">";
    i=i+1;
    myNewCell = myNewRow.insertCell(2);
    myNewCell.innerHTML = "<input type='text' name=aa"+i+">"; 
    document.form1.textfield1.value=i;
    }
      

  3.   

    <!--alert(YourId.rows(0).cells(0).innerText);//显示第一行,第一列的数据 -->
    <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>
    <script language="JaScript"> //另一个版本的增加行和列
    var obj;
     var 
    jnkcHTML='<input>'; function addRow(){ obj = jnkcTable.insertRow(); for 
    (i=0;i<jnkcTable.rows[0].cells.length;i++){ obj.insertCell().innerHTML = 
    jnkcHTML; } } function addCell(){ for(i=0;i<jnkcTable.rows.length;i++){ obj = 
    jnkcTable.rows[i]; obj.insertCell().innerHTML = jnkcHTML; } } </script>
      

  4.   


    方法有好多:可以用DOM方法,也可以用DHTML
    1。obj=yourTableId.insertRow();
       for(t=0;t<yourTableId.rows(1).cells.length;t++)
       {cellobj=obj.insetCell();
        cellobj.innerText="test";
       }2.yourTableId.firstChild.innerHTML+=yourTableId.firstChild.firstChild.innerHTML3.newObj=yourTableId.firstChild.firstChild.clineNode(true);
      yourTableId.firstChild.appendChild(newObj);4.yourTableId.firstChild.innerHTML+=yourTableId.rows(1).outerHTML;