Click here to Skip to main content
Licence 
First Posted 8 Dec 2002
Views 295,847
Bookmarked 70 times

Scrollable HTML Table

By | 6 Sep 2003 | Article
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>
<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

About the Author

Wagner DosAnjos



United States United States

Member



Sign Up to vote   Poor Excellent
Add a reason or comment to your vote: x
Votes of 3 or less require a comment

Comments and Discussions

 
You must Sign In to use this message board. (secure sign-in)
 
Search this forum  
 FAQ
    Noise  Layout  Per page   
  Refresh
GeneralNot working inside div tag ""' PinmemberMember 366988923:25 29 May '09  
GeneralComplete scrollable table Pinmembershahib4:56 17 Nov '08  
General"out of stack space" error Pinmembermikem429:55 23 Apr '08  
Generalonly first line aligns correctly - solved Pinmemberniik3:39 26 Sep '07  
QuestionScrollable table with percentage width PinmemberSmitaU0:33 25 Sep '07  
GeneralChange input value in footer Pinmembertitus691:11 22 Mar '07  
GeneralHelp me with Horizontal scroll Pinmembermanivd18:50 29 Nov '06  
QuestionHow to make scrollbar work dynamic? Pinmemberabergdavid10:13 14 Nov '06  
GeneralScrollbars not displaying with the XHTML DOCTYPE PinmemberRick-N-Roll12:19 28 Sep '06  
GeneralScrollable table that dynamically resizes columns -- no need to preset widths for IE Pinmemberdizzee_rascal15:55 18 Jul '06  
GeneralfixTableWidth Problem Pinmemberchris lasater6:15 19 Jan '06  
QuestionScrollable HTML Table Pinmemberndhai5:35 3 Dec '05  
Generalsome table work on javascript Pinsusssumera nazli7:47 14 Oct '05  
QuestionHow to make horizontal scrolling Pinmembersach_oz20:53 9 Sep '05  
GeneralNo scrollbar in Mozilla and netscape Pinmembermarine_costal10:05 5 Jul '05  
GeneralRe: No scrollbar in Mozilla and netscape PinmemberRohit Joshi4:09 23 Feb '07  
GeneralRe: No scrollbar in Mozilla and netscape PinmemberTerri Layman10:09 17 Sep '08  
GeneralRe: No scrollbar in Mozilla and netscape Pinmemberfrankfry3:59 22 Sep '08  
QuestionRe: No scrollbar in Mozilla and netscape Pinmemberslymenk2:05 8 May '09  
GeneralRe: No scrollbar in Mozilla and netscape Pinmemberslamb85:04 24 Mar '10  
Generalprogram not compiling, stops at thead PinmemberLisaleb15:00 15 Jun '05  
Questionsorting? Pinmemberraforaez4:22 7 Jun '05  
GeneralMozilla Firefox support PinsussAnonymous23:12 19 May '05  
GeneralRe: Mozilla Firefox support PinmemberRohit Joshi4:10 23 Feb '07  
GeneralNo scrollbar in Mozilla Pinmemberclairelw0:30 23 Mar '05  

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

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

Permalink | Advertise | Privacy | Mobile
Web04 | 2.5.120517.1 | Last Updated 7 Sep 2003
Article Copyright 2002 by Wagner DosAnjos
Everything else Copyright © CodeProject, 1999-2012
Terms of Use
Layout: fixed | fluid