473,574 Members | 2,900 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 1832
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.javas cript:
.bgColor is an attribute of a table cell and seems to work properly
except as noted above.
I suggest you use style.backgroun d-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.l ength;n++) {
if (myCells[n].name == 'blah')
myCells[n].style.backgrou nd-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.javas cript:
>.bgColor is an attribute of a table cell and seems to work properly
except as noted above.

I suggest you use style.backgroun d-color instead of .bgColor
style.backgroun dColor might work better :-)

--
Randy
Chance Favors The Prepared Mind
comp.lang.javas cript 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.javas cript:
Evertjan. said the following on 5/20/2007 1:39 PM:
>Don Lancaster wrote on 20 mei 2007 in comp.lang.javas cript:
>>.bgColor is an attribute of a table cell and seems to work properly
except as noted above.

I suggest you use style.backgroun d-color instead of .bgColor

style.backgroun dColor 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
3474
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 trying to extract the stock information after having downloaded the HTML and converted to XML (well-formed HTML) using XSL and XPATH and am unable. ...
4
6144
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 should contain a few "boxes" (these are HTML- tables) which should be all of the same width. So, I attributed the left column with 'width="170"' and...
3
2766
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 field is not filled out. However in Netscape NONE of the required field validations occurs at all in Netscape. The form is posting correctly because...
2
17074
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 alignments and div widths are off. It's as if firefox has a different definition of a pixel than safari. Here is the url:...
34
2815
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 style="margin: 0" onload="preloadImages();"> <table border="0" cellPadding="5" cellSpacing="0" width="100%"> <tr vAlign="top">
3
1656
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 details don't forward. PHP is enabled on the windows server host site. I don't get any errors it just stays on the submit form. below is the scripts...
1
2263
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; left:180; background-color:#f0f0f0"> <% Dim conn dim objrs
4
1427
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 the function show() to call in the data from the secondary asp page. However, when I click on the record in the list, nothing happens. The...
4
2070
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 stumped. What am I doing wrong? <table BORDER=3 WIDTH="500" > <tr> <td WIDTH="100" BGCOLOR="#FFCC00"> <center><b><font face="Arial,Helvetica">Col...
10
5417
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 have to the select the text itself to make the link select. I don't know If I've explained it well... I tried height:100%, and width:100%; in the...
0
7835
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
1
7847
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
8132
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...
1
5645
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...
0
5332
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...
0
3769
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3787
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1365
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
1096
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...

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.