A table ruler is a helpful mechanism that allows the user to highlight sections of a selected HTML table every time the mouse is placed over each of its rows. Naturally, this simple rollover effect permits users to keep track of the row currently being viewed, in this way increasing the table’s overall usability. This is the third article in a four-part series on creating table rulers.
Making Table Rulers Work with Multiple Tables - The full source code of the improved table ruler (Page 4 of 4 )
If you’re anything like me, then it’s probable that you may want to see how the table ruler created in the previous section can be used with multiple tables. So, below I coded a another (X)HTML file that shows how this JavaScript program can be put to work with a couple of sample tables. Here’s how this file looks:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
As depicted above, the table ruler is now capable of highlighting the rows of multiple HTML tables. In the previous code sample, the tables in question have been targeted by assigning a “ruledtable” value to their “class” attribute, but logically IDs can be used as well.
And finally, to complement the previous explanation, here are a couple of screen shots that show the table ruler in action. Take a look at them, please:
Hopefully, the above images give you an approximate idea of the way that the table ruler can be used with a pair of sample HTML tables. Of course, there’s plenty of room to improve the functionality of this JavaScript application, so feel free to tweak all of the code samples shown in this tutorial.
Final thoughts
In this third episode of the series, I explained how to build an improved version of the table ruler, which is capable of working with several HTML tables. As you saw before, creating such a web application was actually a no-brainer process that only required using some basic DOM scripting.
In the next chapter, I’ll be demonstrating how to develop a table ruler by using yet another approach. This time, it’ll be created with the assistance of the jQuery JavaScript framework.
Now that you know the subject of the forthcoming tutorial, you don’t have any excuses to miss it!
DISCLAIMER: The content provided in this article is not warranted or guaranteed by Developer Shed, Inc. The content provided is intended for entertainment and/or educational purposes in order to introduce to the reader key ideas, concepts, and/or product reviews. As such it is incumbent upon the reader to employ real-world tactics for security and implementation of best practices. We are not liable for any negative consequences that may result from implementing any information covered in our articles or tutorials. If this is a hardware review, it is not recommended to open and/or modify your hardware.