how do do this?

K

Ken Williams

This doesn't work.

function jsTest(cellname)
{
document.all.cellname.bgColor = '#bbbbbb';
}


I get the javascript error 'document.all.cellname' is null or not and
object. I want javascript to "translate" the cellname into what its
value is, not the string cellname.

(e-mail address removed)
 
P

Peter Michaux

This doesn't work.

function jsTest(cellname)
{
document.all.cellname.bgColor = '#bbbbbb';
}

I get the javascript error 'document.all.cellname' is null or not and
object. I want javascript to "translate" the cellname into what its
value is, not the string cellname.

document.all[cellname]bgColor

<URL: http://www.jibbering.com/faq/#FAQ4_39>

It is pretty old school to be using document.all but I'll assume you
have a good reason for using it instead of giving the cell an id and
using document.getElementById(cellId).

Peter
 
E

Evertjan.

Peter Michaux wrote on 04 dec 2007 in comp.lang.javascript:
This doesn't work.

function jsTest(cellname)
{
document.all.cellname.bgColor = '#bbbbbb';
}

I get the javascript error 'document.all.cellname' is null or not and
object. I want javascript to "translate" the cellname into what its
value is, not the string cellname.

document.all[cellname]bgColor

needs an extra dot:

document.all[cellname].bgColor

=============

Better perhaps use a cell number or row/cell numbers?

var myCell = document.getElementById('myTable').cells[23];

var myCell = document.getElementById('myTable').rows[3].cells[5];

=============

and please look at and use css styles:

myCell.style.backgroundColor = '#ff0000';

myCell.style.padding = '1px 5px 1px 20px';
 
T

Thomas 'PointedEars' Lahn

Peter said:
This doesn't work.

function jsTest(cellname)
{
document.all.cellname.bgColor = '#bbbbbb';
}

I get the javascript error 'document.all.cellname' is null or not and
object. I want javascript to "translate" the cellname into what its
value is, not the string cellname.
document.all[cellname]bgColor

document.all[cellname].bgColor

It is pretty old school to be using document.all [...]

ACK, as is using bgColor. CSS has been around for almost 11 years now.


PointedEars
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,147
Messages
2,570,833
Members
47,378
Latest member
BlakeLig

Latest Threads

Top