PDA

View Full Version : Sorting table-rows, not cell-data


Jerome
04-03-2003, 04:34 PM
Hi,

I like to sort the data from a table in alfhabetical order from a till z

On the moment i have it already working, however what i did was not so clever, because i change the data from the cells with innerHTML.

I simply loop through all records and determine with innerHTML if data > yes or no, if so I change the data from the cell.

Instead I would like to change the complete rows, so when I have:

<tr id="1"><td id="a1">AAAAAA</td></tr>
<tr id="2"><td id="a2">CCCCCC</td></tr>
<tr id="3"><td id="a3">BBBBBB</td></tr>

The result needs to look like:

<tr id="1"><td id="a1">AAAAAA</td></tr>
<tr id="3"><td id="a3">BBBBBB</td></tr>
<tr id="2"><td id="a2">CCCCCC</td></tr>

I already determine the data, but how can i change the rows?

document.getElementsByTagName('tr') where document.getElementById(row-number)

Hmm. not sure how to achieve this

Thanks a lot,
Jerome

Vladdy
04-03-2003, 05:07 PM
http://www.vladdy.net/webdesign/DOM_Tables.html
see the sort function listing

Jerome
04-04-2003, 01:47 PM
Vladdy,

Thanks for the outstanding discription,

Again a member for the - tables only for tabular data - club!

Ciao,
Jerome