View Full Version : How to use DOM to control cellpadding/cellspacing???
tired&lonely
10-04-2002, 11:11 AM
Is there a way to control cellpadding or cellspacing of a table using some form of the following code?:
document.getElementsByTagName('table').item(#)...
Also, is there another form of this code that will eliminate just the top or bottom border of a table, maybe similar to this:
document.getElementsByTagName('table').item(5).topborder = "0"
:confused:
glenngv
10-04-2002, 01:04 PM
to eliminate top and bottom border:
document.getElementById('tbl').style.borderWidth='0px 2px 0px 2px'; //top right bottom left
to change cellpadding and cellspacing:
document.getElementById('tbl').cellPadding='2px'
document.getElementById('tbl').cellSpacing='3px'
where tbl is the id of the table.
tired&lonely
10-04-2002, 03:07 PM
Hello glenngv,
The cellPadding and cellSpacing work nicely, but I can't seem to get the following to work:
document.getElementsByTagName('table').item(5).style.borderWidth='0px 2px 2px 2px';
...to eliminate the top border. Do I have the syntax correct? For my application, I can't reference the table by ID, so I must find some way to use getElementsByTagName('table') instead of document.getElementById('tbl'). Can it be done?
:confused: :confused:
ASAAKI
10-05-2002, 08:07 PM
not sure, but the way i know it is that it's just 'border', not 'borderWidth'
ASAAKI
10-05-2002, 08:21 PM
oops, just checked it out. it's right, it works fine.
tired&lonely
10-06-2002, 01:50 AM
ASAAKI, what works???!!! That's kinda vague. The following STILL isn't working for me, so what am I doing wrong?:
document.getElementsByTagName('table').item(5).style.borderWidth='0px 2px 2px 2px';
:confused: :confused: :confused:
ASAAKI
10-06-2002, 11:25 AM
Originally posted by tired&lonely
document.getElementsByTagName('table').item(5).style.borderWidth='0px 2px 2px 2px';
is working fine with me... i don't know what it's got against u... :confused:
ASAAKI
10-06-2002, 11:29 AM
the only thing i can think of is that u might have gotten the wrong item number... maybe forgotten that js starts with 0, so that would be item(4) not (5) .... sorry if i'm wrong..
tired&lonely
10-06-2002, 10:23 PM
Thanks, glenngv & ASAAKI. It does work - I just had to move it down past the other code lines affecting that same table - weird.
vBulletin® v3.8.2, Copyright ©2000-2012, Jelsoft Enterprises Ltd.