[solved] How to use get(name) in JS code

  • What is wrong?
    Thanks.

    4 Mal editiert, zuletzt von Fernando (29. November 2020 um 06:32) aus folgendem Grund: Solved by Panoyun

  • Thanks Klaus,

    Sorry, I don't understand yet, that is bad in the use of "name" variable.

    I tried to use it to get the name of hotspot that run the action and pass the property "userdescription" of this hotspot to JavaScript variable "hint".

    But I do not know to do that and have tried and search help without success *confused*

    I hope that you could help me.

    Best regards,
    Fernando

  • function filldata() {
    var krpano = document.getElementById("krpanoSWFObject");
    var name = "myhsname";
    var hint = krpano.get("hotspot["+name+"].userdescription");
    alert(hint);
    }

    or better:

    function filldata() {
    var krpano = document.getElementById("krpanoSWFObject");
    var name = "myhsname";
    var hs = krpano.hotspot.getItem(name);
    alert(hs.userdescription);
    }

  • Hi friend Index
    My question is a little different.
    I need that the var "name" captures the hotspot's name that triggers the action: I don't want to manually set the hotspot name.
    When coding in krpano for example: trace (get(hotspot[get(name)].userdescription)); I don't need to declare the hotspot name because "get name" does that function automatic.
    In the same way I need JS to detect the hotspot name that triggers the action.

    Best regards and very thankful for your quick help.
    Fernando

  • ok, but this is a special condition, for example in an onclick action.

    or

    Code
    krpano.actions.filldata = function(name) {  // take care not to overwrite any krpano actions!
       var krpano = document.getElementById("krpanoSWFObject");
       var userdescription = krpano.get("hotspot["+name+"].userdescription");
       alert("userdescription=" + userdescription);
    };
    
    
    <hotspot name="..." onclick="filldata(get(name));" />

  • There is always one for you

Jetzt mitmachen!

Sie haben noch kein Benutzerkonto auf unserer Seite? Registrieren Sie sich kostenlos und nehmen Sie an unserer Community teil!