在IE下,tr是tbody的子对象,添加到table下是看不到的

解决方案 »

  1.   

    table.childNodes[0].insertAdjacentElement("beforeEnd",tr);
      

  2.   

    需要添加在FORM中才能调用楼上说的也没错
      

  3.   

    换一个思路也可以实现的这是我写的一个动态的,仅供参考:<html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=gb2312">
    </head><body>
    <form method="post" name="form">
      <table align="center" width="90%" bgcolor="#FFFFFF" border="1" cellspacing="0" cellpadding="0" bordercolordark="#FFFFFF" bordercolor="#FFFFFF" bordercolorlight="#000000" style="font-size:9pt">
    <tr>
      <td align="center" id="upid0">&nbsp;</td>
    </tr>
       <tr>
      <td>行数:<input type="text" name="no" size="3" maxlength="3" class="show" onClick="this.value=''">条
      <input type="button" value="添加" onClick="setid();"></td>
    </tr>
      </table>
    </form>
    </body>
    </html>
    <script language="javascript">
    function setid()
    {
    str0='';
    if(!window.form.no.value)
    window.form.no.value=1;
    for(i=1;i<=window.form.no.value;i++)
    {
    str0+='<input type="text" size=55 name="Temp'+i+'"><br>';
    }
    window.upid0.innerHTML=str0+='<br>';
    }
    </script>