Click to See Complete Forum and Search --> : Another problem: Accessing a <div> thru JS


karayan
07-23-2003, 11:00 AM
I have a named division in my HTML and I want to have a script make it invisible. When I say:

divName = "blabla" ;
if (d.getElementById || d.all){
if (d.getElementById) obj=d.getElementById(divName);
else if (d.all) obj=d.all[divName];
obj.style = 'display:none;';
}

it complains about it, saying "member not found." Yet when I access obj.id, I get the right div id (blabla). What am I missing?

Thanks.

George

AdamBrill
07-23-2003, 11:28 AM
Could you post your entire source? It's hard to tell what's wrong with just snippets. ;)

karayan
07-23-2003, 11:44 AM
That's all there is, really. The error goes away when I comment the

obj.style = 'display:none;'

line out.

Is style a property of divisions? Is there another way to make the division invisible through Javascript?

AdamBrill
07-23-2003, 11:57 AM
Change this:

obj.style = 'display:none;';

to this:

obj.style.display = 'none';

I should have notice that before... ;)