View Full Version : Dynamically refering to elements
taboca
09-09-2003, 09:49 PM
How can we dynamically access a given element. Lets say that I have about 50 views in a canvas document.
I would like to access the View1, View2, View3, based on a counter..
Something like document.getElementById and pass a string which is like f(counter).
Thanks,
Marcio
antun
09-09-2003, 09:58 PM
Every view has a subviews array, so you can reference a particular subview as follows:
<view name="myview">
<view name="a" />
<view name="b" />
<view name="c" />
</view>
<script>
var foo = myview.subviews[1];
</script>
... foo would be a pointer to the view named "b".
If you truly want a global way of addressing a view, you can give it a name instead of an id.
-Antun
antun
09-09-2003, 10:02 PM
If you truly want a global way of addressing a view, you can give it a name instead of an id.
Ooops! I meant to say give it an id instead of a name, not the other way around.
If you say:
<view id="foo" />
Then you can address that view from anywhere in your app, just by writing "foo". No need for getElementById.
-Antun
huntedman
10-10-2005, 05:09 AM
my code is like this:
var str_id = "justanid"
var etext = new edittext(someview);
etext.setAttribute("id", str_id);
how can I find out if a control already exists with the id str_id...
thanx,
Arthur.
shunting
01-07-2008, 08:23 AM
That is, addressing the wrapper itself, or an element outside the wrapper.
vBulletin® v3.8.4, Copyright ©2000-2012, Jelsoft Enterprises Ltd.