I'm thinking there is maybe just a confusion here between a DOM 'id' (which
lets you search the DOM for a particular node) and an OL 'id'. In OL, giving
an node and id means there will be a global variable that refers to that
object, so there is no need to "look up" or "search for" an id:
<videoview id="foo" [..] />
foo.setAttribute('visible', false);
is all you need. No need for the intermediate `bar` variable, but if you
insist:
var bar = foo;
bar.setAttribute('visible', false);
will work too.
On 2010-04-21, at 14:33, Max Carlson wrote:
> I think you'd want global[bar].setAttribute(...). The global object should
> have entries for all globals, so you can use the dynamic property lookup
> feature of JavaScript (foo[bar]) to do that...
>
> Regards,
> Max Carlson
> OpenLaszlo.org
>
> On 4/21/10 6:45 AM, Michaela Merz wrote:
>>
>> I am trying to hide a videoview. For whatever reason, it won't work with
>> name, only with id.
>>
>> Now suppose I have
>>
>> <videoview id="foo" [..] />
>>
>> var bar = "foo";
>>
>> Javascript:
>>
>> var ix = document.getElementById(bar);
>> ix.doSomething();
>>
>> OL:
>>
>> bar.setAttribute("visible","0"); -> Failed
>>
>> How am able able to access 'setAttribute' when the id of the element is
>> within a variable?
>>
>> Thanks.
>>
>> Michaela
>>
>>
>>
>>