You are not logged in.

Dear visitor, welcome to krpano.com Forum. If this is your first visit here, please read the Help. It explains in detail how this page works. To use all features of this page, you should consider registering. Please use the registration form, to register here or read more information about the registration process. If you are already registered, please login here.

1

Thursday, May 2nd 2019, 11:27am

Get selecteditemindex within javascript function.

Hi,
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,
Alex.

EDIT:
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>

<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>

<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();"/>
</combobox>



<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;

alert(scnCd);


]]></action>

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


2

Tuesday, May 7th 2019, 12:17pm

Hi,

the 'selecteditemindex' property is an attribute not a function - see here:
https://krpano.com/plugins/combobox/#selecteditemindex

That means the correct syntax would be:

Source code

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


Best regards,
Klaus