<!doctype html public "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title> New Document </title>
<meta name="Generator" content="EditPlus">
<meta name="Author" content="">
<meta name="Keywords" content="">
<meta name="Description" content="">
</head><body>
<script language=javascript>
function abc(){
newRow            = document.all.aa.insertRow()
newCell           = newRow.insertCell()
newCell.innerHTML = document.all.bb.value
newCell           = newRow.insertCell()
newCell.innerHTML = document.all.bb.value
newCell           = newRow.insertCell()
newCell.innerHTML = document.all.bb.value
}
</script>
<table id=aa border=1></table>
<input id=bb type=text value="±í&cedil;&ntilde;&micro;&Auml;&Auml;&Uacute;&Egrave;&Yacute;"><input type=button value=&raquo;&shy;&sup3;&ouml; onclick=abc()>
</body>
</html>

解决方案 »

  1.   

    for(i=0;i<aa.rows.length;i++)
    {
      newCell = aa.rows[i].insertCell(x);
      newCell.innerHTML = document.all.bb.value
    }
      

  2.   

    <!doctype html public "-//W3C//DTD HTML 4.0 Transitional//EN">
    <html>
    <head>
    <title> New Document </title>
    <meta name="Generator" content="EditPlus">
    <meta name="Author" content="">
    <meta name="Keywords" content="">
    <meta name="Description" content="">
    </head><body>
    <script language=javascript>
    function abc(){
    newRow            = document.all.aa.insertRow()
    newCell           = newRow.insertCell()
    newCell.innerHTML = document.all.bb.value
    }
    function cba()
    {
    if(document.all.aa.rows.length==0)
    abc()
    else
    {
    for(i=0;i<aa.rows.length;i++)
    {
      newCell = aa.rows[i].insertCell(aa.rows[i].cells.length);
      newCell.innerHTML = document.all.bb.value
    }
    }
    }
    </script>
    <table id=aa border=1></table>
    <input id=bb type=text value="±í&cedil;&ntilde;&micro;&Auml;&Auml;&Uacute;&Egrave;&Yacute;"><input type=button value=&raquo;&shy;&sup3;&ouml; onclick=abc()>
    <input name="button" type=button onClick=cba() value=插入列>
    </body>
    </html>