Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    Regular Coder
    Join Date
    Oct 2002
    Posts
    299
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Sorting table-rows, not cell-data

    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

  • #2
    Senior Coder
    Join Date
    Jun 2002
    Location
    Nashua, NH
    Posts
    1,724
    Thanks
    0
    Thanked 0 Times in 0 Posts
    http://www.vladdy.net/webdesign/DOM_Tables.html
    see the sort function listing
    Vladdy | KL
    "Working web site is not the one that looks the same on common graphical browsers running on desktop computers, but the one that adequately delivers information regardless of device accessing it"

  • #3
    Regular Coder
    Join Date
    Oct 2002
    Posts
    299
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Vladdy,

    Thanks for the outstanding discription,

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

    Ciao,
    Jerome


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •