written on:8 Oct, 2007 by Alen Grakalic
Introducing Tablecloth
Delicious | Digg | Stumble | Reddit | Float | Subscribe to RSS Feed
Tablecloth is lightweight, easy to use, unobtrusive way to add style and behavior to your html table elements. By simply adding 2 lines of code to your html page you will have styled and active tables that your visitors will love :)
It features:
- Adding even/odd class names to alternative rows.
- Adding over and out class names for mouse over and mouse out states.
- If set to true Tablecloth will highlight rows or columns (or both).
- If set to true Tablecloth adds selected state on click. Based on preferences it then selects rows or columns (or both). Unselect elements by clicking anywhere on the page.
- It leaves room for your upgrade. It has easily editable function that is called when you click on table cell that you can use for your own code.
Any comments you might have about Tablecloth you can post here.
About the author:
Designer, developer and a passionate standardista with large experience in all types of front-end work. Started to get involved with web in 1999. and turned freelance in 2005., the same year he started Css Globe. Alen's work has been featured on numerous css galleries including famous Css Zen Garden official list. Available for contract work.
Enjoyed the article?
Subscribe to our RSS feed or share it with your friends.
Delicious | Digg | Stumble | Reddit | Float | Subscribe to RSS Feed
Comments
Subscribe
Join 5000+ subscribers and receive our content instantly.
Follow us on Twitter
Want to be the first to know when a new article is published?
Sponsors

Look Professional with FreshBooks

Sitegrinder 2 Photoshop Plugin
Recent Articles
- Purist or a Freak
- CSS do's and dont's Part 2- Markup
- Easiest Tooltip and Image Preview Using jQuery
- 4 Uber Cool Css Techniques For Links
- CSS do's and dont's Part 1: CSS Selecting




EmanuelBlagonic on 8 Oct, 2007 wrote:
I will try it on my future designs.
Nice job Alen, once again :)
cssglobe on 8 Oct, 2007 wrote:
pagerss reader on 8 Oct, 2007 wrote:
Same view in both browsers. I can suggest you to add some options on this good lock table
like sort in some order from header row. I can also search a script for this but you can do it better from me. I see a ready script for emulate ms excel.
Regards and good job
Good luck with version 2
cssglobe on 9 Oct, 2007 wrote:
Paul on 9 Oct, 2007 wrote:
Jason on 9 Oct, 2007 wrote:
cssglobe on 9 Oct, 2007 wrote:
MindStalker on 9 Oct, 2007 wrote:
cssglobe on 9 Oct, 2007 wrote:
Mickele on 9 Oct, 2007 wrote:
ps: sorry for my english
james on 9 Oct, 2007 wrote:
Stupid Developers on 9 Oct, 2007 wrote:
mike on 9 Oct, 2007 wrote:
Mike
james on 9 Oct, 2007 wrote:
Raul Riera on 9 Oct, 2007 wrote:
Sol Irvine on 9 Oct, 2007 wrote:
I tried to tweak the code to apply tablecloth only to a class, rather than all table tags, but I haven't been able to get it working. Is it possible?
Thanks!
James McDugal on 9 Oct, 2007 wrote:
cssglobe on 9 Oct, 2007 wrote:
Forrest Vodden on 9 Oct, 2007 wrote:
Otherwise, great work!
cssglobe on 9 Oct, 2007 wrote:
shane plasebo on 10 Oct, 2007 wrote:
Then I change in the HTML the id of the div container...
mike on 10 Oct, 2007 wrote:
daniel on 10 Oct, 2007 wrote:
Great work!
cssglobe on 10 Oct, 2007 wrote:
cssglobe on 10 Oct, 2007 wrote:
Darren Hoyt on 10 Oct, 2007 wrote:
Re: sorting, could you implement some of the AJAX-y concepts found here?
myheaditches on 10 Oct, 2007 wrote:
pagerss reader on 11 Oct, 2007 wrote:
1. Standard mathematical formulas for some mark cell more then 2 if value is int :)
2. Mark more than one cell like select several cells in different row and column.
3. third suggestions to make simple script :)
Good luck cssglobe
Marcelo on 11 Oct, 2007 wrote:
myheaditches on 11 Oct, 2007 wrote:
http://upsidedownturtle.com/tablecloth/tablecloth.js
Line 23 has the definable class, and there is now an if statement on line 42.
Tommy on 12 Oct, 2007 wrote:
rosenthal on 12 Oct, 2007 wrote:
Apple on 13 Oct, 2007 wrote:
saunameister on 14 Oct, 2007 wrote:
thanks for work
D on 16 Oct, 2007 wrote:
I'd like to use the script, except for the ActiveX problem.
Brad on 17 Oct, 2007 wrote:
[Wed Oct 17 08:21:30 2007] [error] [client 151.193.220.29] (8)Exec format error: exec of '/var/www/cgi-bin/tablecloth/tablecloth.css' failed, referer: http://xxxxxxxxx/cgi-bin/prod_env.cgi
[Wed Oct 17 08:21:30 2007] [error] [client 151.193.220.29] Premature end of script headers: tablecloth.css, referer: http://xxxxxxxxxx/cgi-bin/prod_env.cgi
[Wed Oct 17 08:21:30 2007] [error] [client 151.193.220.29] (8)Exec format error: exec of '/var/www/cgi-bin/tablecloth/tablecloth.js' failed, referer: http://xxxxxxx/prod_env.cgi
[Wed Oct 17 08:21:30 2007] [error] [client 151.193.220.29] Premature end of script headers: tablecloth.js, referer: http://xxxxxx/cgi-bin/prod_env.cgi
Any ideas?
Paul Irish on 19 Oct, 2007 wrote:
Looking forward to the update. :)
great script.
Nathan L on 21 Oct, 2007 wrote:
Leo on 22 Oct, 2007 wrote:
Thanks again
Leo
paul irish on 22 Oct, 2007 wrote:
Take a look at getActualCellIndex() from
http://www.javascripttoolbox.com/lib/table/source.php
Paul M on 23 Oct, 2007 wrote:
angel rodriguez leon on 24 Oct, 2007 wrote:
cssglobe on 25 Oct, 2007 wrote:
cssglobe on 25 Oct, 2007 wrote:
Lizzam on 30 Oct, 2007 wrote:
I'd like to suggest an on-the-fly edit data function, like those you can find in Google Spreadsheets, and I think this page would be of help
http://www.quirksmode.org/dom/cms.html
sam on 2 Nov, 2007 wrote:
Is there a forum for tablecloth? I have a few questions i would like to discuss.
Has anyone figure a way to limit table cloth to specific tables instead of all?
Stan on 13 Nov, 2007 wrote:
objectred on 20 Nov, 2007 wrote:
Can anybody tell me how to have a specific row pre-selected on page load, or how to use another element on the page to target a specific table row?
Thanks!
jas on 22 Nov, 2007 wrote:
junlisondra on 3 Jan, 2008 wrote:
Melanie on 23 Jan, 2008 wrote:
Great work and thank you once again =)
Matt on 4 Feb, 2008 wrote:
Just wondering if anyone has worked out how to limit the script to only work on the one table? The tablecloth.js file affects the scripting I have on another table on my site.
Thanks
Sam on 8 Feb, 2008 wrote:
I think that would be neat.
?? on 14 Feb, 2008 wrote:
Levic on 3 Mar, 2008 wrote:
It's a very nice script, but it's very slow on IE7 when the table have a lot of columns, but on Firefox or Safari, there is no pb, an idea ?
Bye
MAXMAS on 4 Mar, 2008 wrote:
I hope it will be modify and will not influence all forms on page.
Thanks a lot!!
Pneumatiky on 11 Mar, 2008 wrote:
Jon Egil on 19 Mar, 2008 wrote:
Predaj pneumatik on 22 Mar, 2008 wrote:
Petar on 2 Apr, 2008 wrote:
rockananda on 7 Apr, 2008 wrote:
Phill on 10 Apr, 2008 wrote:
Have one issue when adding and removing elements (table rows in my case), Tablecloth is not working correctly.
I am implementing something like the example here:
http://www.mredkj.com/tutorials/tableaddrow.html
but when I add a new row to the table the class comes up as undefined.
<td class="undefined">TEST DATA</td>
Any suggestions on how I could get the Tablecloth functionality to the user added row?
Thanks in advance and looking forward to future releases.
--Phill
Ezhilan on 15 Apr, 2008 wrote:
jonathan on 17 Apr, 2008 wrote:
I also agree that it would be great to be able to select multiple rows/columns and even sort.
Another good addition would be for it to be able to add the values in cells (e.g have a column which adds the values of the selected columns).
Jon on 21 May, 2008 wrote:
Bernike on 11 Jun, 2008 wrote:
I am experiencing a problem at the moment. Think it might be similar to Phill’s error on 10 April 2008. The tablecloth worked 100% until I had to add a couple of columns to my table and now it seems to go wonky. I am getting an “ojb has no properties” error. Any suggestions?
Bernike on 11 Jun, 2008 wrote:
fallentemplar on 4 Jul, 2008 wrote:
I do have a performance problem though, when I have more than 500 rows (im only selecting rows not cols), the script script slows to a CRAWL, as takes ~5 seconds on a quad core machine respond, FF and IE...
Anyway to solve this problem? I do see that you are doing linear redrawing....that's o(n)...but I suppose you can get it down to o(2) or even o(3) by keeping track of which rows a user selects..I could just completly rewrite the script..but the script already works, any help making it more efficent would be nice
Thanks!
fallentemplar on 4 Jul, 2008 wrote:
cannot paste onto page, wont submit, probaly wont handle the " or '....
email me if you want one.
online shopping on 5 Jul, 2008 wrote:
Charles on 21 Jul, 2008 wrote:
Beau Smith on 23 Jul, 2008 wrote:
I had one small issue which I'd like to submit as a patch. I wanted to style one row specifically using a class, but the Tablecloth javascript would replace the class with "even" or "odd". In the below patch, if there is an existing class, odd/even class is appended, otherwise just the odd/even class is added:
tablecloth.js - line 50
old: tr[i].className = css;
new: tr[i].className = tr[i].className ? tr[i].className + " " + css : css;
Autobazar Pocasie Spoje on 24 Jul, 2008 wrote:
oil painting reproductions on 25 Jul, 2008 wrote:
Erik on 25 Jul, 2008 wrote:
Work With 1 Class on 30 Jul, 2008 wrote:
Work with 1 id on 30 Jul, 2008 wrote:
agamemnus on 10 Aug, 2008 wrote:
And many thanks to Beau Smith for that additional class mod!
TANVE on 14 Aug, 2008 wrote:
Jonathan on 26 Aug, 2008 wrote:
Is there any way to get both to work on the same page?