Click here to Skip to main content
15,881,812 members
Articles / Web Development / HTML

Fix headers, footer, and left columns of an HTML table

Rate me:
Please Sign up or sign in to vote.
3.67/5 (2 votes)
28 May 2007CPOL1 min read 33.2K   833   12   1
How to fix headers, footer, and left columns of an HTML table by calling a JavaScript function.

Introduction

This code helps fix headers, footer, and left columns of an HTML table. The code uses the different possibilities of JavaScript for dynamically adding HTML components and playing with CSS styles.

This works really well on IE 6 (other versions not tested) but with Mozilla / Firefox I didn't manage to obtain the same results: I had to downgrade some functionalities.

If somebody wishes to migrate the IE code so that it works with Mozilla / Firefox, it would be great (I have no time to do it for the moment). In fact, the major problems are that CSS expressions are available only with IE and that relative / absolute position doesn't work the same in Mozilla / Firefox.

Background

The concept is simple: the table is inserted in a DIV, which offers the possibility to have scrollbars. Header, footer, and left columns are positioned relatively, and CSS expressions make them always visible. The DIV and IFRAME are positioned to hide invisible cells and HTML components (IFRAME for select boxes, DIV for everything else).

The code is not simple, and requires JavaScript experience to be improved. But analyzing it is a good way to learn the many possibilities offered by this powerful language.

Using the code

Using this library is very simple : all you have to do is call a JavaScript function on an existing table, without modifying existing code (except adding an HTML ID on your table, if not present).

JavaScript
var t = new ScrollableTable('myScrollTable', height, width, numberLeftColumns);

The included Zip contains the JS library, and an example HTML page presenting several use cases.

History

This code was inspired from this article: http://www.webtoolkit.info/scrollable-html-table.html.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
France France
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions

 
Questionproblem in using your code. Pin
prabhu46014-Apr-14 20:03
prabhu46014-Apr-14 20:03 
i have downloaded the code and run it, freezing functionality is not working.

and iam getting a error in js file saying : "javascript runtime error object doesn't support property or method 'setexpression' ".

please suggest ASAP.

Regards,
Prabhu Kumar.T

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.