473,399 Members | 2,774 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,399 software developers and data experts.

Remove background color from table cell

Frinavale
9,735 Expert Mod 8TB
Hi there,

I'm using JavaScript to highlight a row or column in a table.
I have created a CSS class that changes the background colour to a light blue and I apply this class to the cells in the selected row/column.

It works great most of the time but sometimes the cell may have an inline style sets background colour to yellow. This, of course, overwrites the background colour in the class that is being used to highlight the cell.

(Also, all of the cells contain at least one hyperlink and if the cell's background colour is set to yellow, this hyperlink's background colour is also set to yellow using an inline style)

When applying the class to the cell I have attempted to remove the background color for the cell (and hyperlink) but this does not appear to work.

Could someone please point out what I'm doing wrong:

Expand|Select|Wrap|Line Numbers
  1. function SelectColumn(colIndex)
  2. { Deselect(); //<----deselects any rows/columns selected
  3.   var gridView = document.getElementById('myGridTable');
  4.   var rows = gridView.getElementsByTagName('tr');
  5.   for(i=0; i < rows.length; i++)
  6.   {
  7.      var cells = rows[i].getElementsByTagName('td');
  8.      if(colIndex<cells.length)
  9.      {
  10.        cells[colIndex].className = cells[colIndex].className +' selectedRowOrColumn';
  11.        cells[colIndex].style.backgroundcolor = '';
  12.        var links = cells[colIndex].getElementsByTagName('a');
  13.        for(linkIndex = 0; linkIndex < links.length; linkIndex++)
  14.        {
  15.            links[linkIndex].style.backgroundcolor = '';
  16.        }
  17.    } 
  18. }
  19.  
  20. //......
  21. }

Thanks

-Frinny
Feb 2 '09 #1
3 10510
acoder
16,027 Expert Mod 8TB
The "C" in style.backgroundColor is a capital one.
Feb 2 '09 #2
Frinavale
9,735 Expert Mod 8TB
Thank you!

It's working now.

This just proves that developing with VB.NET has made me lazy.
I didn't even think to look at the capitalization.
Feb 2 '09 #3
acoder
16,027 Expert Mod 8TB
That's one of the first things to look out for. It also can't harm to be vigilant on cases in lenient languages too.
Feb 2 '09 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

23
by: MattB | last post by:
Hello please help, I have a table cell with a div in it. The div has a width of 300px. but when it is rendered it puts extra space into the table cell. Here's the style <style>...
3
by: kAldam | last post by:
I am currently using IE 6.0 and 5.5 and the scenario is the following. I have a span that contains text, and the span is beign contained by a table cell (this is the way thing need to be in my...
7
by: John A. | last post by:
Hello all! I've got a big bunch of pages using tables for layout. Eventually I'll get them set up with more modernized code, but in the meantime I'd like to slip in a little quick holiday...
3
by: T | last post by:
I am attempting to create a menu using <div> and <span> tags within a table cell. When the page loads, some of the classes don't seem to be applied. If I hover over the menu everything is fine...
2
by: Sugapablo | last post by:
Can anyone help me out with some code to change three table cells (<td>) when one is hovered over? I have a calendar grid where each day is made up of three table cells and I want all three to...
31
by: Arthur Shapiro | last post by:
I'm the webmaster for a recreational organization. As part of one page of the site, I have an HTML "Calendar at a Glance" of the organization's events for the month. It's a simple table of a...
5
by: Greg N. | last post by:
Hi folks, I have a table cell with a background image, something like <td background=landscape.jpg height=200></td> The sole purpose of this code is to display the image inside that table...
1
by: Thanks | last post by:
I have a routine that is called on Page_Init. It retrieves folder records from a database which I display as Link Buttons in a table cell. I set the table cell's bgcolor to a default color (say...
5
by: Michael | last post by:
Is there a way to specify a background-image for a html table cell in a theme's css file. I know a lot of things I can't do... can't figure out one that I can do: 1) ~/ Images/logo.gif...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.