js 操作table!  一个页面中 有两个TABLE1,2
table1中显示查询出来的记录,table2中是空的!
在table1中选中一条记录,点添加,然后在table2中显示,相应的在table1中删除记录,
然后点取消,table2中的被添加记录删除,而后在table1中显示!  
这个操作  有没有例子,  有谁能给我解释一下!? 
那位仁兄 帮忙 下,感激不尽啊!

解决方案 »

  1.   

    可以用div模拟啊,现在很少用table的点击了按钮执行jsdiv.innerHTML属性
      

  2.   

    另附js操作table代码:
    <html>
        <head>
            <meta http-equiv="Content-Type" content="text/html; charset=gb2312">
            <title>增加Table行</title>
        </head>
        <script>
            function addRow(obj)
            {
            //添加一行
            var newTr = testTbl.insertRow();
            //添加两列
            var newTd0 = newTr.insertCell();
            var newTd1 = newTr.insertCell();
            //设置列内容和属性
            newTd0.innerHTML = '<input type=checkbox id="box4">'; 
            newTd1.innerText= '新加行';
            }
        </script>
        <body>
            <table id="testTbl" border=1>
                <tr id="tr1">
                    <td ><input type=checkbox id="box1"></td>
                    <td id="b">第一行</td>
                </tr>
                <tr id="tr2">
                    <td ><input type=checkbox id="box2"></td>
                    <td id="b">第二行</td>
                </tr>
                <tr id="tr3">
                    <td ><input type=checkbox id="box3"></td>
                    <td>第三行</td>
                </tr>
            </table>        
            <br />
            <input type="button" id="add" onclick="addRow();" value="Add Row" />
        </body>
    </html> 
      

  3.   

    二楼的这个例子很好啊,谢谢你啊! 不过怎么样才能体现在另一个table中呢? 在第二个table中做到添加的效果! 然后还有删除的效果!
      

  4.   

    在table1中点击添加相应记录,然后选中的相应记录在table2中添加,同时table1中删去这条记录!     反之操作  点取消添加记录,在table2中移除记录,又重新加到table1中!