Forum Discussion
MichaelHebert
3 years agoCommunity Member
Using Text Entry Fields and Javascript
Hello e-learning peeps, do you ever have what you think is a great creative idea, but lack the skill (and have limited time to develop the skill needed) to implement it in Storyline? Sadly this is w...
RichardWatson
3 years agoSuper Hero
Michael,
Try this. I'm still learning JavaScript, but it works for your specific situation..
Richard
var player = GetPlayer();
var learnerName = player.GetVar("FirstName_LastName");
// Calculate the hex value
var hexText = convertToHex(learnerName);
// Set the 'HexDisplay' variable in Storyline with the hexText
player.SetVar("HexDisplay", hexText);
function convertToHex(input) {
var hexString = '';
for (var i = 0; i < input.length; i++) {
var charCode = input.charCodeAt(i);
var hexValue = charCode.toString(16);
hexString += hexValue + ' ';
}
return hexString.toUpperCase(); // Convert the hexString to uppercase (optional)
}
Related Content
- 3 months ago