Hello, syntax question. How to find out the number of elements
<test a1="1" a2="2" a3="3" />
How to find out the number of "a№"?
How to get the value "a№" by its number?
How to get the name "a№" by its number?
Hello, syntax question. How to find out the number of elements
<test a1="1" a2="2" a3="3" />
How to find out the number of "a№"?
How to get the value "a№" by its number?
How to get the name "a№" by its number?
Hi,
i was also trying to get this info some time ago..
https://krpano.com/forum/wbb/inde…&threadID=17357
i think San7 wants to know the amount of attributes which is 3 in the example.
a1
a2
a3
and then call them for index number, name and value.
I might be wrong though..
Tuur
Yes for example
<test a1="tt" a2="yy" a3="uu" />
trace (test [item] .count) --> 3 (3 elements)
trace (test [2]) --> yy(the second element contains yy)
trace (test [2].name) --> a2 (name of the second element)
But this is the wrong syntax, these are my fantasies
Hi,
please see the thread Tuur linked, there you see the answer:
https://krpano.com/forum/wbb/inde…81170#post81170
Best regards,
Klaus
Klaus, thanks for the helpful example!
This works when there is a name:
<test name="test1" a1="tt" a2="yy" a3="uu" />
<action autorun="onstart" type="Javascript"><![CDATA[
var layer = krpano.get("test[test1]");
var attributes = layer.getattributes();
for (var i=0; i < attributes.length; i++)
{
var attrib = attributes[i];
var value = layer[attrib];
krpano.set("value", value);
krpano.set("attrib", attrib);
krpano.call("trace(attrib,=,value)");
}
]]></action>
Display More
Can this be done if there is no name?
It works! Thanks!
Don’t have an account yet? Register yourself now and be a part of our community!