473,698 Members | 2,222 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Change 'cell color' on dynamically added table cells

25 New Member
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 2066
xNephilimx
213 Recognized Expert New Member
@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
2490
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 change its text contents from a link elsewhere in the page? I have a rought idea that I'll need something like 'id' in my <td> tags but while I have a greater understanding of server-side programming langauges like PHP, javascript is still very new...
5
4114
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", but nothing happened. Also, how can I set the mouse cursor to be an arrow when it hovers over these table cells? (It's an insertion bar now.) Thanks!
3
4755
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
3026
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 has three HtmlTableCell objects, and each cell contains a single control added to the HtmlTableCell's Controls collection. The basic table renders correctly, but the controls within the HtmlTableCell objects do not; the cells are just empty. (Just...
2
2788
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 TableRow row = New TableRowI Answer_1 = New TextBox Answer_1.Width = New Unit("100px")
1
3362
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 New TableRow Dim objTableCell As New TableCell
0
996
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. Any text that I try to apply to the other cells is ignored when the page is viewed. An example of the code is listed below. All help is greatly apprediated. Gregg
1
5815
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 perform the actions: // sometimes you have to shake the container to make browser see // your style changes (shake = hide+show) vat tableState = table.style.display; // save display value of the table
0
9157
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9028
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8861
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7728
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6518
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5860
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4619
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
2330
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2001
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.