View Single Post
  #7 (permalink)  
Old June 27th, 2007, 12:02 AM
zaerymoghaddam zaerymoghaddam is offline
Authorized User
 
Join Date: Jun 2007
Location: Tehran, Tehran, Iran.
Posts: 39
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi bucky483

It's very simple. You can use 'moveRow' method of table object. It takes two index in rows collection and replaces corresponding rows in table.

You can change your methods to something like this :

    function thisrow(x)
    {
        TableLocation = x.sectionRowIndex;

        if(whichrow)
        {
            whichrow.style.backgroundColor = 'white';
        }
        whichrow = x;
        whichrow.style.backgroundColor = 'gray'; // not grey
    }

    function MoveUp()
    {
        var tablebody = document.getElementById('table1');
        if(TableLocation > 0)
        {
            tablebody.moveRow(TableLocation, TableLocation - 1);
            TableLocation = TableLocation - 1;
        }
    }

    function MoveDown()
    {
        var tablebody = document.getElementById('table1');
        if((TableLocation > 0) && (TableLocation < tablebody.rows.length - 1))
        {
            tablebody.moveRow(TableLocation, TableLocation + 1);
            TableLocation = TableLocation + 1;
        }
    }




Ehsan Zaery Moghaddam
Reply With Quote