Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Javascript > how do do this?

Reply
Thread Tools

how do do this?

 
 
Ken Williams
Guest
Posts: n/a
 
      12-04-2007
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.



 
Reply With Quote
 
 
 
 
Peter Michaux
Guest
Posts: n/a
 
      12-04-2007
On Dec 3, 7:51 pm, Ken Williams <kenw...@yahoo.com> wrote:
> 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
 
Reply With Quote
 
 
 
 
Evertjan.
Guest
Posts: n/a
 
      12-04-2007
Peter Michaux wrote on 04 dec 2007 in comp.lang.javascript:

> On Dec 3, 7:51 pm, Ken Williams <kenw...@yahoo.com> wrote:
>> 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';



--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
 
Reply With Quote
 
Thomas 'PointedEars' Lahn
Guest
Posts: n/a
 
      12-05-2007
Peter Michaux wrote:
> On Dec 3, 7:51 pm, Ken Williams <kenw...@yahoo.com> wrote:
>> 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
--
var bugRiddenCrashPronePieceOfJunk = (
navigator.userAgent.indexOf('MSIE 5') != -1
&& navigator.userAgent.indexOf('Mac') != -1
) // Plone, register_function.js:16
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: How include a large array? Edward A. Falk C Programming 1 04-04-2013 08:07 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57