Go Back   CodingForums.com > :: Client side development > JavaScript programming > DOM and JSON scripting

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 10-04-2002, 10:11 AM   PM User | #1
tired&lonely
New Coder

 
Join Date: Aug 2002
Posts: 69
Thanks: 0
Thanked 0 Times in 0 Posts
tired&lonely is an unknown quantity at this point
Question How to use DOM to control cellpadding/cellspacing???

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"

tired&lonely is offline   Reply With Quote
Old 10-04-2002, 12:04 PM   PM User | #2
glenngv
Supreme Master coder!


 
glenngv's Avatar
 
Join Date: Jun 2002
Location: Los Angeles, CA Original Location: Philippines
Posts: 10,241
Thanks: 0
Thanked 112 Times in 111 Posts
glenngv will become famous soon enough
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.
__________________
Glenn
_____________________________________________
Play Tower of Hanoi Android app (Ad-FREE!)
Play Tower of Hanoi Android app (FREE!)
Go to Tower of Hanoi Leaderboard
Play Tower of Hanoi Facebook app
glenngv is offline   Reply With Quote
Old 10-04-2002, 02:07 PM   PM User | #3
tired&lonely
New Coder

 
Join Date: Aug 2002
Posts: 69
Thanks: 0
Thanked 0 Times in 0 Posts
tired&lonely is an unknown quantity at this point
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?

tired&lonely is offline   Reply With Quote
Old 10-05-2002, 07:07 PM   PM User | #4
ASAAKI
Regular Coder

 
Join Date: Jul 2002
Location: This little Earth.
Posts: 383
Thanks: 0
Thanked 0 Times in 0 Posts
ASAAKI is an unknown quantity at this point
not sure, but the way i know it is that it's just 'border', not 'borderWidth'
__________________
'If you don't stand for something, you'll fall for anything.'
ASAAKI is offline   Reply With Quote
Old 10-05-2002, 07:21 PM   PM User | #5
ASAAKI
Regular Coder

 
Join Date: Jul 2002
Location: This little Earth.
Posts: 383
Thanks: 0
Thanked 0 Times in 0 Posts
ASAAKI is an unknown quantity at this point
oops, just checked it out. it's right, it works fine.
__________________
'If you don't stand for something, you'll fall for anything.'
ASAAKI is offline   Reply With Quote
Old 10-06-2002, 12:50 AM   PM User | #6
tired&lonely
New Coder

 
Join Date: Aug 2002
Posts: 69
Thanks: 0
Thanked 0 Times in 0 Posts
tired&lonely is an unknown quantity at this point
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';

tired&lonely is offline   Reply With Quote
Old 10-06-2002, 10:25 AM   PM User | #7
ASAAKI
Regular Coder

 
Join Date: Jul 2002
Location: This little Earth.
Posts: 383
Thanks: 0
Thanked 0 Times in 0 Posts
ASAAKI is an unknown quantity at this point
Quote:
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...
__________________
'If you don't stand for something, you'll fall for anything.'
ASAAKI is offline   Reply With Quote
Old 10-06-2002, 10:29 AM   PM User | #8
ASAAKI
Regular Coder

 
Join Date: Jul 2002
Location: This little Earth.
Posts: 383
Thanks: 0
Thanked 0 Times in 0 Posts
ASAAKI is an unknown quantity at this point
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..
__________________
'If you don't stand for something, you'll fall for anything.'
ASAAKI is offline   Reply With Quote
Old 10-06-2002, 09:23 PM   PM User | #9
tired&lonely
New Coder

 
Join Date: Aug 2002
Posts: 69
Thanks: 0
Thanked 0 Times in 0 Posts
tired&lonely is an unknown quantity at this point
Thanks, glenngv & ASAAKI. It does work - I just had to move it down past the other code lines affecting that same table - weird.
tired&lonely is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 01:50 AM.


Advertisement
Log in to turn off these ads.