我用insertRow()行,怎么让插入的行靠前,也就是本来列表页面有3条数据,在新增页面选择一条数据过来,但这条数据没有保存到数据库的,原来那3条数据时从数据库读出来的,而新增这条临时数据,怎么让它排在那3条数据之前?
如: 
 序号  姓名 年龄
  1    张三  20
  2    李四  17
  3    王五  21
  4    刘强  18
这里的第四条数据是用 insertRow()插入的,而前面3条数据是从数据库循环出来的。怎么让插入新的行时让它排在第一?

解决方案 »

  1.   

    用sql语句 select * from 表名 order by sysdate desc试一下;
      

  2.   

    我都说了的嘛。。1、2、3条数数据时从数据库读出来的,而第4条数据时从弹出窗口选择的,是临时的数据,就是用insertRow()插入的临时数据,新增的临时数据要排在从数据库读出来的数据之前麻烦回答之前仔细看下在回答
      

  3.   

    JS中insertRow()因该只能一行按顺序插入。
    LZ可以换个思路
    加零时数据先清空表。先insertRow()插入零时数据,然后循环insertRow()你数据库中的数据,这样就在最上面了
      

  4.   

    JS中insertRow()因该只能一行按顺序插入。
    LZ可以换个思路
    加零时数据先清空表。先insertRow()插入零时数据,然后循环insertRow()插入数据库中的数据,这样零时数据就在最上面了
      

  5.   

    <html>
    <head>
    <script type="text/javascript">
    function insRow()
      {
      var x=document.getElementById('myTable').insertRow(0)
      var y=x.insertCell(0)
      var z=x.insertCell(1)
      y.innerHTML="NEW CELL1111111111111"
      z.innerHTML="NEW CELL2222222222222"
      }
    </script>
    </head><body>
    <table id="myTable" border="1">
    <tr>
    <td>Row1 cell1</td>
    <td>Row1 cell2</td>
    </tr>
    <tr>
    <td>Row2 cell1</td>
    <td>Row2 cell2</td>
    </tr>
    <tr>
    <td>Row3 cell1</td>
    <td>Row3 cell2</td>
    </tr>
    </table>
    <br />
    <input type="button" onclick="insRow()" value="插入行"></body>
    </html>