473,219 Members | 2,047 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,219 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 10455
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...
1
isladogs
by: isladogs | last post by:
The next online meeting of the Access Europe User Group will be on Wednesday 6 Dec 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, Mike...
0
by: veera ravala | last post by:
ServiceNow is a powerful cloud-based platform that offers a wide range of services to help organizations manage their workflows, operations, and IT services more efficiently. At its core, ServiceNow...
0
by: VivesProcSPL | last post by:
Obviously, one of the original purposes of SQL is to make data query processing easy. The language uses many English-like terms and syntax in an effort to make it easy to learn, particularly for...
3
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 3 Jan 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). For other local times, please check World Time Buddy In...
0
by: jianzs | last post by:
Introduction Cloud-native applications are conventionally identified as those designed and nurtured on cloud infrastructure. Such applications, rooted in cloud technologies, skillfully benefit from...
0
by: mar23 | last post by:
Here's the situation. I have a form called frmDiceInventory with subform called subfrmDice. The subform's control source is linked to a query called qryDiceInventory. I've been trying to pick up the...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 7 Feb 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:30 (7.30PM). In this month's session, the creator of the excellent VBE...
1
by: davi5007 | last post by:
Hi, Basically, I am trying to automate a field named TraceabilityNo into a web page from an access form. I've got the serial held in the variable strSearchString. How can I get this into the...
0
by: MeoLessi9 | last post by:
I have VirtualBox installed on Windows 11 and now I would like to install Kali on a virtual machine. However, on the official website, I see two options: "Installer images" and "Virtual machines"....

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.