User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the JavaScript / DHTML / AJAX section within the Web Development category of DaniWeb, a massive community of 423,010 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 3,933 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our JavaScript / DHTML / AJAX advertiser: Lunarpages Web Hosting
Views: 4954 | Replies: 4
Reply
Join Date: Jul 2006
Posts: 11
Reputation: AndrewSmith is an unknown quantity at this point 
Rep Power: 3
Solved Threads: 0
AndrewSmith AndrewSmith is offline Offline
Newbie Poster

Help Change left-border of a table cell with javascript

  #1  
Aug 30th, 2006
Hi guys....
I am having trouble changing the color of the LEFT border in a table.

i'm using the following javascript:

document.getElementById("cell1").style.border-left="3px red solid";

cell1 is the correct id of the table cell.
If i take away the "-left" part in "border-left", it will change the border of the whole cell. Problem is, i need to change only SPECIFIC borders.

Any Suggestions?

Rock On
AddThis Social Bookmark Button
Reply With Quote  
Join Date: Dec 2004
Posts: 1,590
Reputation: tgreer is an unknown quantity at this point 
Rep Power: 7
Solved Threads: 35
Colleague
tgreer tgreer is offline Offline
Made Her Cry

Re: Change left-border of a table cell with javascript

  #2  
Aug 30th, 2006
Try "borderLeft" instead. One of the unfortunate aspects of web development is that the CSS property may or may not have a corresponding JavaScript property, and they don't always map directly to each other. Also, as you can see, the spelling will differ.

So, "style.borderLeft" is the JavaScript property that changes the "border-left" CSS declaration.

Here's a nice cross-reference: http://codepunk.hardwar.org.uk/css2js.htm
Last edited by tgreer : Aug 30th, 2006 at 3:19 pm.
Reply With Quote  
Join Date: Jun 2004
Location: Hemet, CA
Posts: 429
Reputation: FC Jamison is on a distinguished road 
Rep Power: 5
Solved Threads: 18
Colleague
FC Jamison's Avatar
FC Jamison FC Jamison is offline Offline
Posting Pro in Training

Re: Change left-border of a table cell with javascript

  #3  
Sep 1st, 2006
Javascript doesn't use the hyphens that are present in CSS.

As a general rule, if the CSS style is border-left, margin-top, etc, the javascript equivalent will be borderLeft, marginTop, etc.

What do the call that...camel code? Something like that.
Reply With Quote  
Join Date: Dec 2004
Posts: 1,590
Reputation: tgreer is an unknown quantity at this point 
Rep Power: 7
Solved Threads: 35
Colleague
tgreer tgreer is offline Offline
Made Her Cry

Re: Change left-border of a table cell with javascript

  #4  
Sep 1st, 2006
camelCase
Reply With Quote  
Join Date: Jun 2004
Location: Hemet, CA
Posts: 429
Reputation: FC Jamison is on a distinguished road 
Rep Power: 5
Solved Threads: 18
Colleague
FC Jamison's Avatar
FC Jamison FC Jamison is offline Offline
Posting Pro in Training

Re: Change left-border of a table cell with javascript

  #5  
Sep 1st, 2006
That's it!
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

DaniWeb JavaScript / DHTML / AJAX Marketplace
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

Thread Tools Display Modes

Similar Threads
Other Threads in the JavaScript / DHTML / AJAX Forum

All times are GMT -4. The time now is 3:57 am.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC