Home     |     .Net Programming    |     cSharp Home    |     Sql Server Home    |     Javascript / Client Side Development     |     Ajax Programming

Ruby on Rails Development     |     Perl Programming     |     C Programming Language     |     C++ Programming     |     IT Jobs

Python Programming Language     |     Laptop Suggestions?    |     TCL Scripting     |     Fortran Programming     |     Scheme Programming Language


 
 
Cervo Technologies
The Right Source to Outsource

MS Dynamics CRM 3.0

Javascript / Client Side Development

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: d@tinaja.com

Please visit my GURU's LAIR web site at http://www.tinaja.com

Don Lancaster said:

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: d@tinaja.com

Please visit my GURU's LAIR web site at http://www.tinaja.com

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)

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/

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)

Add to del.icio.us | Digg this | Stumble it | Powered by Megasolutions Inc