Welcome to the Tactical Panda Websites Tables Pages
Welcome to Tactical Panda
Home Page
About Us
Contact Us
Javascripts
Tables
Free stuff on the net
Website Templates
HTML and DHTML
Using Graphics
Using Colours
Cascading Stlye Sheets
Help Page

Tactical Panda Websites

Tables (5)

No Lines, BorderColorLight, BorderColorDark

Let's say that you don't want your table to be divided up by lines. Let's have another look at a table as a starting point. Remember this table from the previous page?

R1C1 R1C2 R1C4
R2C1 R2C4
R3C1 R3C4
R4C1 R4C4

Let's remove the cell's lines.

R1C1 R1C2 R1C4
R2C1 R2C4
R3C1 R3C4
R4C1 R4C4

To do this I added a few words to the line:

<TABLE border="2" bordercolor="blue" cellpadding="3" cellspacing="2">

...by adding the bits in red:

<TABLE border="2" frame="box" rules="groups" bordercolor="blue" cellpadding="3" cellspacing="2">

BorderColorLight & BorderColorDark

I can tell you're impressed! But there's more! How about adding a bit of flair to the border of the table by introducing two colours instead of the one (blue).

Back to the original code (the 'minus the lines' one):

<TABLE border="2" frame="box" rules="groups" bordercolor="blue" cellpadding="3" cellspacing="2">

Okay, let's add a couple more words to get this effect:

R1C1 R1C2 R1C4
R2C1 R2C4
R3C1 R3C4
R4C1 R4C4

I have done two things differently to the original code (apart from the additions). I have changed the color="blue" to a hexidecimal code so I don't confuse your browser, and increased the border width from 2 to 4 thereby increasing the effect.

The entire code is now (with additions in red):

<TABLE border="4" frame="box" rules="groups" bordercolorlight="#0080FF" bordercolordark="#004080" cellpadding="3" cellspacing="2">
<TR>
<TD align="center"> R1C1 </TD>
<TD align="center" colspan="2" rowspan="4"> R1C2 </TD>
<TD align="center"> R1C4 </TD>
</TR>
<TR>
<TD align="center"> R2C1 </TD>
<TD align="center"> R2C4 </TD>
</TR>
<TR>
<TD align="center"> R3C1 </TD>
<TD align="center"> R3C4 </TD>
</TR>
<TR>
<TD align="center"> R4C1 </TD>
<TD align="center"> R4C4 </TD>
</TR>
</TABLE>

Notice that 'bordercolor=...' now reads 'bordercolorlight=...' and 'bordercolordark=...'. It's entirely up to you how you want the colours to look - I will leave that choice to your particular taste!

Adding Javascript Powered Colours

Now let's add a bit of Javascript to make a cell change colour when the mouse cursor moves over it. Here's an example, simply place your cursor on any of the cells:

cell 1 cell 2 cell 3

To start with you will have to place this piece of script in the <HEAD> section of your page:

<script language="JavaScript1.2">
function changeto(highlightcolor){
source=event.srcElement
if (source.tagName=="TR"||source.tagName=="TABLE")
return
while(source.tagName!="TD")
source=source.parentElement
if (source.style.backgroundColor!=highlightcolor&&source.id!="ignore")
source.style.backgroundColor=highlightcolor
}
function changeback(originalcolor){
if (event.fromElement.contains(event.toElement)||source.contains(event.toElement)||source.id=="ignore")
return
if (event.toElement!=source)
source.style.backgroundColor=originalcolor
}
</script>

...and then change the opening line of your <TABLE> to read:

<table onMouseover="changeto('blue')" onMouseout="changeback('')" width="50%" cellpadding="2" cellspacing="2" border="2">

The rest of the table coding is the same as you had before, only the opening line is different. Within reason you can change the colour to anything you want, here I have used blue.

...and that's it for now!

If you have a problem with tables, and you would like some further help or advice, please feel free to contact us.


[1] [2] [3] [4] [5]

Previous Page Top of the page Home Page Contact Us Help Page

Problems? Comments? Contact our Webmaster!
Copyright © 2003 Tactical Panda. All rights reserved.