Thanks!!!!
it worked fine.
"Lasse Reichstein Nielsen" <lrn@hotpop.com> escribió en el mensaje
news:llq8ynjz.fsf@hotpop.com...[color=blue]
> "atomo" <atomo@none.cl> writes:
>[color=green]
> > Hi, i'm wondering why this hiding and showing function works on IE (6)[/color][/color]
but[color=blue][color=green]
> > it doesn't work in Mozilla Firebird (0.7)[/color]
>
> I wonder why it works in IE. But, alas, it does, and we have to live
> with it.
>[color=green]
> > function fnc_show(num){
> >
> > for(i=1;i<7;i++){
> > eval("t_" + i + ".style.display = \"none\"");[/color]
>
> Never use eval to find the value of a variable or property. Never.
> Almost never use eval at all. It is slow and inefficient, and it
> hides errors far too well.
>
> You have an element with the id "t_1". You then assume that that
> element is available as a global variable of the same name. That
> is true for IE, but luckily not for many other browsers (no need
> to pollute the global namespace like that!).
>
> To get an element from its id, use
> document.getElementById("t_"+i).style.display = "none";
>[color=green]
> > }
> > eval("t_" + num + ".style.display = \"inline\"");[/color]
>
> and
>
> document.getElementById("t_"+num).style.display = "inline";
>[color=green]
> > }
> >
> > t_1, t_2 ...t_7 are the ids for TR elements in a table, i.e. with
> > fnc_show(3), it will show only t_3. This works without a problem on IE,[/color][/color]
but[color=blue][color=green]
> > it seems to do nothing in Mozilla, i only get an error telling that t_1[/color][/color]
is[color=blue][color=green]
> > not defined.[/color]
>
> That is because there is no global variable called "t_1".
>[color=green]
> > I'm wondering too, if there is a better way to do it, cause i read that[/color][/color]
eval[color=blue][color=green]
> > function is inefficient .[/color]
>
> Oh, yes! Very inefficient! And there is (almost) always a better way.
> What that better way is, depends on what you try to do.
> The FAQ says: <URL:http://jibbering.com/faq/#FAQ4_40>
>
> /L
> --
> Lasse Reichstein Nielsen -
lrn@hotpop.com
> DHTML Death Colors:[/color]
<URL:http://www.infimum.dk/HTML/rasterTriangleDOM.html>[color=blue]
> 'Faith without judgement merely degrades the spirit divine.'[/color]