473,387 Members | 1,379 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.

Problems with .bgColor



I am trying to change a group of background colors by calculating their
names in a loop . Names are cfh13, cfh15, cfh17, etc...

Unlooped code like

cfh17.bgColor="#CCFFFF" ;

works just fine.

Code that does NOT involve a background color change but is calculated
within a loop works just fine, such as...

form[curedg + "s"]["value"] = "zorch" ;

But this does not....

form["cfh" + 17]["bg.Color"] = "#CCFFFF" ;

What am I doing wrong and how can I loop changing a named group of
background colors?
--
Many thanks,

Don Lancaster voice phone: (928)428-4073
Synergetics 3860 West First Street Box 809 Thatcher, AZ 85552
rss: http://www.tinaja.com/whtnu.xml email: do*@tinaja.com

Please visit my GURU's LAIR web site at http://www.tinaja.com
May 20 '07 #1
5 1821
Lee
Don Lancaster said:
>
I am trying to change a group of background colors by calculating their
names in a loop . Names are cfh13, cfh15, cfh17, etc...

Unlooped code like

cfh17.bgColor="#CCFFFF" ;

works just fine.

Code that does NOT involve a background color change but is calculated
within a loop works just fine, such as...

form[curedg + "s"]["value"] = "zorch" ;

But this does not....

form["cfh" + 17]["bg.Color"] = "#CCFFFF" ;

What am I doing wrong and how can I loop changing a named group of
background colors?
Your examples of what works and what doesn't should be more
similar, in order to help to determine where the problem lies.

There is no attribute named "bg.Color". If that was just a typo
in your post, and doesn't appear in your code, then you need to
learn to copy from your code and paste into your posts to avoid
wasting everybody's time.

Assuming that this also works:

form["cfh17"]["bgColor"] = "#CCFFFF" ;

then this should work:

form["cfh" + 17].bgColor = "#CCFFFF" ;

If the first case doesn't work, then the problem may be that
cfh17 isn't a form element, so you can't access it via the
form collection.
--

May 20 '07 #2
Lee wrote:
Don Lancaster said:
>>

I am trying to change a group of background colors by calculating their
names in a loop . Names are cfh13, cfh15, cfh17, etc...

Unlooped code like

cfh17.bgColor="#CCFFFF" ;

works just fine.

Code that does NOT involve a background color change but is calculated
within a loop works just fine, such as...

form[curedg + "s"]["value"] = "zorch" ;

But this does not....

form["cfh" + 17]["bg.Color"] = "#CCFFFF" ;

What am I doing wrong and how can I loop changing a named group of
background colors?


Your examples of what works and what doesn't should be more
similar, in order to help to determine where the problem lies.

There is no attribute named "bg.Color". If that was just a typo
in your post, and doesn't appear in your code, then you need to
learn to copy from your code and paste into your posts to avoid
wasting everybody's time.

Assuming that this also works:

form["cfh17"]["bgColor"] = "#CCFFFF" ;

then this should work:

form["cfh" + 17].bgColor = "#CCFFFF" ;

If the first case doesn't work, then the problem may be that
cfh17 isn't a form element, so you can't access it via the
form collection.


..bgColor is an attribute of a table cell and seems to work properly
except as noted above.

The greater problem is to change the background colors of certain table
cells by their input name with a loop, instead of one at a time.

Unlooped code appears as a small part of http://www.tinaja.com/demo28a.asp
--
Many thanks,

Don Lancaster voice phone: (928)428-4073
Synergetics 3860 West First Street Box 809 Thatcher, AZ 85552
rss: http://www.tinaja.com/whtnu.xml email: do*@tinaja.com

Please visit my GURU's LAIR web site at http://www.tinaja.com
May 20 '07 #3
Don Lancaster wrote on 20 mei 2007 in comp.lang.javascript:
.bgColor is an attribute of a table cell and seems to work properly
except as noted above.
I suggest you use style.background-color instead of .bgColor
The greater problem is to change the background colors of certain table
cells by their input name with a loop, instead of one at a time.

Table cells do not have an input name.

Is a loop not accessing one at a time?

Perhaps you want this:

var myCells = form["cfh" + 17].cells
for (var n=0;n<myCells.length;n++) {
if (myCells[n].name == 'blah')
myCells[n].style.background-color = "#CCFFFF";
}

not tested.

--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
May 20 '07 #4
Evertjan. said the following on 5/20/2007 1:39 PM:
Don Lancaster wrote on 20 mei 2007 in comp.lang.javascript:
>.bgColor is an attribute of a table cell and seems to work properly
except as noted above.

I suggest you use style.background-color instead of .bgColor
style.backgroundColor might work better :-)

--
Randy
Chance Favors The Prepared Mind
comp.lang.javascript FAQ - http://jibbering.com/faq/index.html
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
May 20 '07 #5
Randy Webb wrote on 20 mei 2007 in comp.lang.javascript:
Evertjan. said the following on 5/20/2007 1:39 PM:
>Don Lancaster wrote on 20 mei 2007 in comp.lang.javascript:
>>.bgColor is an attribute of a table cell and seems to work properly
except as noted above.

I suggest you use style.background-color instead of .bgColor

style.backgroundColor might work better :-)
True, my mistake.

--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
May 20 '07 #6

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

Similar topics

0
by: Michael Fork | last post by:
Note: I pasted the code the attachments as plain text after the message (I wasn't able to post it with an attachment...) Attached are the XSL and XML files that I am having problems with. I am...
4
by: Alex Meier | last post by:
I have the following problem: I need a simple, tabular layout in a webshop. - left column: navigation column with approx. 170px width - right column: content area the goal: the left column...
3
by: Rick | last post by:
I have an interesting problem when I run the following code in Netscape (7.02) vs. IE. This page works great in IE and all my controls bring up the validation summary dialog box if the required...
2
by: cbjewelz | last post by:
Hey all. So I'm having problems with cross browser alignments. I'm looking at Safari and Mozilla Firefox. I develop in Safari and so it looks perfect there however in Firefox my vertical...
34
by: aljamala | last post by:
I keep getting this error for the given code region (it actually highlights the line with the body tag): line 42 column 1 - Warning: <trisn't allowed in <bodyelements </head> <body...
3
by: dtvuser | last post by:
Hi, I'm new to PHP and seem to be having soom problems, I'm getting confused with all the different styles of script writing. I've created a PHP script to submit details to my email but the...
1
idsanjeev
by: idsanjeev | last post by:
<%@ Language =vbscript%> <% Option Explicit %> <html> <head><TITLE>VOICE OF BARAUNIANS</TITLE></head> <body> <!--#include file="front.inc"--> <div style="Position:Absolute; width:700; TOP:0;...
4
by: srkidd12 | last post by:
Hello, I am having problems with using AJAX to call information to my primary ASP page from a secondary asp page that brings in the data I want to display. I'm having the onfocus event trigger...
4
by: ronboulder | last post by:
Sorry, I'm new to BYTES.com and posted this first in the articles section.... When I display this HTML in a browser the colors do not work. This has to be something very elementary, but I am...
10
by: magnesium | last post by:
I have this under-construction page, If you try and select the link coming from the bottom with your mouse, you'll notice, that before the actual link is selected, the td background will change. you...
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: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
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
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?
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,...
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...

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.