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

Set bgcolor of a newly added table row?

I'm using the following function to insert a new row in a table. This
works fine - no problems. But, I would like to also set the background
color of the new row and I can't figure out how to do it.

I tried adding: Y.bgcolor='green'; after the Y.innerHTML = Msg1;
but that didn't work.

I tried adding:
document.getElementById('TableX').rows(1).bgcolor= 'green';
at the end of the funtion but that didn't work either.

Can someone give me a clue here?

Thanks

------------------------------------------------
function insRow(Msg1,Msg2)
{
var x=document.getElementById('TableX').insertRow(1);
var Y = x.insertCell(0);
var Z = x.insertCell(1);
Y.innerHTML = Msg1;
Z.innerHTML = Msg2;
}

Jul 23 '05 #1
2 3777
In article <ja********************************@4ax.com>,
ma**********@comcast.net enlightened us with...
I'm using the following function to insert a new row in a table. This
works fine - no problems. But, I would like to also set the background
color of the new row and I can't figure out how to do it.

I tried adding: Y.bgcolor='green'; after the Y.innerHTML = Msg1;
but that didn't work.


That would be b/c the property name is Y.bgColor. Case-sensitive.
Or you can do Y.style.backgroundColor. That one works for more elements than
bgColor does, I think.

--
--
~kaeli~
If a turtle doesn't have a shell, is he homeless or naked?
http://www.ipwebdesign.net/wildAtHeart
http://www.ipwebdesign.net/kaelisSpace

Jul 23 '05 #2
Or...

Y.style.background

The CSS 'background' property is a catch-all for every
background-related attribute; the parser knows which is which by its
data format. Don't use 'bgColor', it's deprecated.

cheers

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Jul 23 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: kindermaxiz | last post by:
hi there i have a mysql table and i want the user to add columns using a php interface and then display the table with the newly added column. I was thinking about putting all the columns...
6
by: Tony Stoker | last post by:
I have a .Net web app that adds a record to a SQL database. After the user adds their record I want to have a link that will link them to their new record! The recordID is a AutoNumber in the...
15
by: @sh | last post by:
Trying to do this, but its not working...?! My aim being to change the bgcolor of the cell upon which the user has rolled over, I'll then replicate this as an OnMouseOut to change it back. ...
3
by: damezumari | last post by:
I am using WinXP and MS Access 2003. I have a list whose row source is an sql. I insert a new record to the table the sql takes its data from. I requery the list and the new record appears. ...
1
by: mike | last post by:
I have a datagridview control and a button on the windows form. I am adding a new row in button click event. When the number of rows grow, the newly added row will not be visible but a scroll bar...
0
by: Sooraj | last post by:
Hi all I am using vb.net 2002. To add records to grid, I click on button and display modal form with various text boxes. f.showdialog() When I save the record (by selecting MAXID from table)...
9
by: =?Utf-8?B?UHJhdmlu?= | last post by:
We are using .net Framework 1.1 We are having one page on which we are using this Grid component. From this page we open a popup for adding new record as well as for editing an existing record...
0
by: Patrick.O.Ige | last post by:
I have a GridView. And i'm using a DetailView to add data to a table that a GridView uses to display data. After adding a row to the table i show the Gridview with the new row added.But i would...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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
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,...
0
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...
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...

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.