Client-side Sorting with the DOM
I'm amazed at how easy it is to sort an HTML table with the DOM and JavaScript. I whipped up a quick modification of Porter's Sort Table Rows demo. The basic enhancements I
made where removing the <a>'s from the table headers, and just adding an onclick
handler to the <th>'s. I also added indicators to display the the current
column/direction that's sorted. Seems to work in most of the browsers too! On Windows
2000, this includes IE6, IE5.5, Opera 7 and Phoenix 0.5. On OS X, the latest versions of
Safari, Chimera, IE, Mozilla and Netscape. It doesn't work on OmniWeb, and the
cursor: pointer
doesn't work on the <th>'s in IE/Mac and IE5.5/Win.
Anyway, you can checkout the
demo or download with
the relevant HTML, .gif and .js files. I've also included it below for your convenience.
I'd love to add this sort of capability to the display tag library.