473,387 Members | 1,721 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,387 software developers and data experts.

Change 'cell color' on dynamically added table cells

Hi all
On my web page I have a 3 column table.
The first cell changes background color when mouseover event occurs.
Something like this :
Expand|Select|Wrap|Line Numbers
  1. <TR><TD onMouseOver="this.bgColor='#00CC00'"
  2. onMouseOut="this.bgColor='#F0FFF0'" >name</TD>
  3. <TD>number</TD>
  4. <TD>address</TD><TR>
This works fine.
Problem starts when I add more rows dynamically to the table using:
insertRow and insertCell
I can't get the added cells to change their color too.
I tried it like this:
Expand|Select|Wrap|Line Numbers
  1. row.cells[0].onmouseover="this.bgcolor='red'";
  2.  
Doesn't work.

Can anybody help ?
Thanks in advance
Jan 8 '09 #1
1 2050
xNephilimx
213 Expert 100+
@nsteiner
That piece of code is wrong, onmouseover expects a function, not a string. The correct way to do that would be:

Expand|Select|Wrap|Line Numbers
  1. row.cells[0].onmouseover = function() {
  2.     this.style.backgroundColor = 'red';
  3. }
  4.  
Jan 8 '09 #2

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

Similar topics

14
by: Reply Via Newsgroup | last post by:
Folks, Say I have a table, ten columns, ten rows - Each with a word in it. I want to change the values of some/all of the cells in the table via a hyperlink. How do I reference each cell and...
5
by: kj | last post by:
Is there a way to dynamically (e.g. upon onClick) change the bgColor attribute of a table cell? I tried cell.setAttribute("bgColor", someColor), where someColor was a string of the form "#RRGGBB",...
3
by: Peter Williams | last post by:
Hi All, I want to write some javascript for a html page which does the following. Imagine that the page contains a table with 2 columns and 3 rows, e.g.: +---+---+ | A | B | +---+---+
3
by: David Whitney | last post by:
All: I have a control that renders a table. As the table is rendered, each row in the table is constructed by creating a run-time (dynamic) object that is derived from an HtmlTableRow. The row...
2
by: Bass Pro | last post by:
How do I access a textbox when it was added to a table cell? I've tried using the findcontrol function with no result. I create it as such... Dim myTable As Table = New Table Dim Row as...
1
by: Owen Mortensen | last post by:
How do I get a dynamically created button control to appear in a dynamically created table cell? Here's what I've tried: While objDR1.Read() Dim objButton As New Button Dim objTableRow As...
0
by: Gregg | last post by:
I'm having a problem dynamically appling cell text values in a table. The problem occurs when I try to set the cell text value in any cell other than the first cell of the frist row in the table....
1
by: r_mun | last post by:
Hello, I think it would be an interesting issue to everyone. What I'd like to do is simply change the style of my dynamically created table cell. I have written the following code to...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

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.