You are not logged in.


Thursday, May 2nd 2019, 11:27am

Get selecteditemindex within javascript function.

I'm very new to Javascript, XML and KrPano, please be gentle!
I have a set of comboboxes and am trying to get the selected item indexes to allow me to generate a code to assign a specific scene to load. Unfortunately my code to get the index is returning as undefined.
Where am I going wrong?
Thanks in advance,

OK, so I've realised that call has no return value, so was never going to work.
I've changed call to get, and while I am no longer getting undefined for each of the values, they still come back as null.
Clearly I'm calling selecteditemindex with incorrect syntax, I shall keep experimenting.

<combobox name="cb1" design="default" align="lefttop" x="10" y="10">
<item name="Set1Op1" caption="Choice1_1" onclick="ldScn();"/>
<item name="Set1Op2" caption="Choice1_2" onclick="ldScn();"/>

<combobox name="cb2" design="default" align="lefttop" x="10" y="110">
<item name="Set2Op1" caption="Choice2_1" onclick="ldScn();"/>
<item name="Set2Op2" caption="Choice2_2" onclick="ldScn();"/>

<combobox name="cb3" design="default" align="lefttop" x="10" y="210">
<item name="Set3Op1" caption="Choice3_1" onclick="ldScn();"/>
<item name="Set3Op2" caption="Choice3_2" onclick="ldScn();"/>

<action name="ldScn" type="Javascript"><![CDATA[

var cb1Val = krpano.get("plugin[cb1].selecteditemindex();");
var cb2Val = krpano.get("plugin[cb2].selecteditemindex();");
var cb3Val = krpano.get("plugin[cb3].selecteditemindex();");

var scnCd = cb1Val+cb2Val+cb3Val;



This post has been edited 1 times, last edit by "doc11235" (May 2nd 2019, 2:45pm) with the following reason: Some progress made.


Tuesday, May 7th 2019, 12:17pm


the 'selecteditemindex' property is an attribute not a function - see here:

That means the correct syntax would be:

Source code

var cb1Val = krpano.get("plugin[cb1].selecteditemindex");

Best regards,