Forum Discussion
JavaScript works but doesn't appear in Storyline
Nathan_Hilliard​ is absolutely right. I don't think you can change the contents of a text box in this way. .textContent won't affect Storyline objects.
Even if monthFlash referred to a DOM element, I don't see how changing textContent would change what the learner sees in Storyline. To display text in Storyline, you update a variable using player.SetVar(), and that variable must be bound to a visible text box in the Storyline project as Nathan suggests. Once you have the variable reference in the text box, you could try something like this:
let monthArray = [
player.GetVar("January"),
player.GetVar("February"),
player.GetVar("March"),
player.GetVar("April"),
player.GetVar("May"),
player.GetVar("June"),
player.GetVar("July"),
player.GetVar("August"),
player.GetVar("September"),
player.GetVar("October"),
player.GetVar("November"),
player.GetVar("December")
];
let index = 0;
function showNextMonth() {
if (index < monthArray.length) {
player.SetVar("monthFlash", monthArray[index]);
index++;
setTimeout(showNextMonth, 300); // 300ms delay between updates
}
}
showNextMonth();