Each input box generates a correlated variable when it's created. Something like textEntry, textEntry1, textEntry2, etc... You can see the variable it creates in the trigger that's also created when the input box is placed.
To grab this value from JavaScript:
var player=GetPlayer();
var js_textVar=player.GetVar("textEntry");
alert(js_textVar); //or whatever you want to do with the value in JS.
I created a Number Variable (Coins) and I´d like to use the final value of the variable as an input in a TextEntry (actually a Numeric Question). Could somebody help me with a javascript code for that?
Give this attachment a try. It may be a timing issue since the variable won't pick up the value of your text box until the box loses focus. If you're trying to pick up the value before leaving the box it may not pick up what you expect.
6 Replies
Each input box generates a correlated variable when it's created. Something like textEntry, textEntry1, textEntry2, etc... You can see the variable it creates in the trigger that's also created when the input box is placed.
To grab this value from JavaScript:
var player=GetPlayer();
var js_textVar=player.GetVar("textEntry");
alert(js_textVar); //or whatever you want to do with the value in JS.
if you're using an iframe or popup window to grab the value, something like this should work (from JS in the iFrame or popup):
var player=parent.GetPlayer();
var js_textVar=player.GetVar("textEntry");
ok guys, thanks for that, ill give it a try.
:}
Hello.
I created a Number Variable (Coins) and I´d like to use the final value of the variable as an input in a TextEntry (actually a Numeric Question). Could somebody help me with a javascript code for that?
Cheers!
Hi There.
so i tried this (i am not in a iframe)
var player = GetPlayer();
var js_textVar = player.GetVar("Input1");
alert(js_textVar);
Nothing,
I by mistake added a variable called (var1) to the slide i am in and gave it a default text of 'hello',
i then used
var player=GetPlayer();
var js_textVar=player.GetVar("var1");
alert(js_textVar);
and get the hello text back in the javascript alert.
so i guess that i am not referencing the input box name correctly.
Any help would be much appreciated.
PS, i did notice there was a variable called TextEntry, but this did not return any results.
-------------------------
post above
we did get the value from a var by doing this
var player=GetPlayer();
var js_textVar=player.GetVar("var1");
alert(js_textVar);
but i am still trying to talk to the input box
Give this attachment a try. It may be a timing issue since the variable won't pick up the value of your text box until the box loses focus. If you're trying to pick up the value before leaving the box it may not pick up what you expect.
This discussion is closed. You can start a new discussion or contact Articulate Support.