http://community.csdn.net/Expert/TopicView.asp?id=3192647

解决方案 »

  1.   

    <div id=id1 contenteditable=true>
    <table align=center border=1 width=80% id=id2> 
    <tr>
    <td>nNum</td>
    <td>nPrice</td>
    <td>nMoney</td>
    </tr>
    <tr id=id3>
    <td id=col3>4</td>
    <td id=col4>10.5</td>
    <td id=col5>40.2</td>
    </tr>
    </table>
    </div>如何在输入nprice和nNum时 nMoney能够自动显示
      

  2.   

    <script>
    function createTable()
    {
    var vTable=document.createElement("table");
    vTable.cellPadding="0";
    vTable.cellSpacing="0";
    vTable.border="1";
    vTable.color="#000000";
    vTable.borderColorDark="#000000";
    vTable.borderColorLight="#FFFFFF";
    for(kIndex=0;kIndex<5;kIndex++)
    {
    var vTr=vTable.insertRow(kIndex);
    for(iIndex=0;iIndex<5;iIndex++)
    {
    vTd=vTr.insertCell(iIndex);
    vTd.innerHTML="<input type=text style='border:0px solid'>";
    }
    }
    DivID.appendChild(vTable);
    }
    </script>
    <input type=button value="创建表格" onclick="createTable();">
    <div id="DivID"></div>
    如果要计算
    假如要计算第三列[金额]的值为一[单价]、二[数量]之积
    可以在vTd.innerHTML="<input type=text style='border:0px solid' onchange=TableID.rows(this.parentElement.sectionRowIndex).cells(3).innerText=1*TableID.rows(this.parentElement.sectionRowIndex).cells(1).innerText*TableID.rows(this.parentElement.sectionRowIndex).cells(2).innerText>"
      

  3.   

    现在的问题是不用<input>控件所以有些事件就不能使用