Click here to Skip to main content
15,887,945 members
Articles / Web Development / HTML
Article

Scrollable HTML Table

Rate me:
Please Sign up or sign in to vote.
4.84/5 (55 votes)
6 Sep 2003 405.8K   7.2K   72   65
Make your HTML tables scrollable with this simple method. No additional coding necessary!

Sample Image - Scrollable_Table.jpg

Introduction

This JavaScript code can be used to convert tables in ordinary HTML into scrollable ones. No additional coding is necessary. All you need to do is put header rows in TBODY and give your table an ID field, include the ScrollableTable.js file and call makeScrollableTable in your document's onLoad method.

HTML
<html>
<head>
<script language=JavaScript src=ScrollableTable.js></script>
</head>

<body onload="makeScrollableTable('tabela',true,'auto');">

<table border=0 id=tabela align=center 
  style="border-color: black; border-style: solid; border-width: 1;">
<thead>
<tr>
  <th bgcolor=blue style="color: white" rowspan=2 valign=bottom>ColA</th>
  <th bgcolor=blue style="color: white" colspan=2 align=center>ColBC</th>
  <th bgcolor=blue style="color: white" colspan=2 align=center>ColDE</th>
  <th bgcolor=blue style="color: white" rowspan=2 valign=bottom>ColF</th>
</tr>
<tr>
  <th bgcolor=blue style="color: white">ColB</th>
  <th bgcolor=blue style="color: white">ColC</th>
  <th bgcolor=blue style="color: white">ColD</th>
  <th bgcolor=blue style="color: white">ColE</th>
</tr>
</thead>
<tbody>
<tr><td>A</td><td>B</td><td>C</td><td>D</td><td>E</td><td>F</td></tr>
<tr><td>A</td><td>B</td><td>C</td><td>D</td><td>E</td><td>F</td></tr>
<tr><td>A</td><td>B</td><td>C</td><td>D</td><td>E</td><td>F</td></tr>
<tr><td>A</td><td>B</td><td>C</td><td>D</td><td>E</td><td>F</td></tr>
<tr><td>A</td><td>B</td><td>C</td><td>D</td><td>E</td><td>F</td></tr>
<tr><td>A</td><td>B</td><td>C</td><td>D</td><td>E</td><td>F</td></tr>
<tr>
  <td>A</td>
  <td>BBBBBBBBBBBBBBBBBBBBBBBBB</td>
  <td>C</td>
  <td>D</td>
  <td>E</td>
  <td>F</td>
</tr>
</tbody>
<tfoot>
<tr>
  <td bgcolor=blue style="color: white" colspan=6 align=center>Footer</td>
</tr>
</tfoot>
</table>
</body>
</html>

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here


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

Comments and Discussions

 
GeneralRe: vertical + horizontal scrolling Pin
gladya23-Sep-04 0:12
gladya23-Sep-04 0:12 
QuestionOnly for IE ? Pin
mhe9-Dec-02 21:26
mhe9-Dec-02 21:26 
AnswerRe: Only for IE ? Pin
Wagner DosAnjos10-Dec-02 3:06
Wagner DosAnjos10-Dec-02 3:06 
GeneralRe: Only for IE ? Pin
Jean-Marc Molina10-Dec-02 23:13
Jean-Marc Molina10-Dec-02 23:13 
GeneralRe: Only for IE ? Pin
Anonymous22-Aug-03 7:59
Anonymous22-Aug-03 7:59 
AnswerRe: Only for IE ? Pin
BillBelliveau22-Apr-04 6:34
BillBelliveau22-Apr-04 6:34 
GeneralRe: Only for IE ? Pin
Member 128234917-Aug-04 13:33
Member 128234917-Aug-04 13:33 
GeneralRe: Only for IE ? Pin
BillBelliveau19-Aug-04 9:42
BillBelliveau19-Aug-04 9:42 
Sticking to specifications isn't a business model unto itself. If a specification say do X but 95% of my customers do Y the specification is meaningless. Appealing to the 5% does a disservice to the 95%. If you need specification, this is the Developer Bible.

I’m trying to build an ROI for cross-browser support and I cannot find one. Citing specifications and exploits is somewhat irreverent. I don’t know that Microsoft has ever met a specification and they have had numerous security flaws, but that hasn’t stopped them. Mozilla is probably no better, they just are under a 1000x smaller microscope.

I’m not necessarily pro MS or a proselyte, but without a realistic ROI…

Looking forward to XAML is even more daunting for cross-browser - anything.

Bill

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.