Forum Discussion

BenKanspedos-8b's avatar
BenKanspedos-8b
Community Member
2 years ago

Display value of variable with line-breaks when populated from javascript

I'm working on a template project where the variables get populated from a javascript that defines and adds the values to the variables.

There is one variable that will often be quite long. I want to include js code that will add a break every 3 lines. But can't do it.

Any ideas?

 

  • Looks solid. Recapping how i think it works ( should work ) checking your images.

    - sentences are split on a .
    - all sentences are added to formattedCxScenario
    - a . is added to the end.
    - i is checked
    - when (i +1) % 3 === 0 it will return true
    - when true a <br> is added.

    Looks correct...
    I would add a console.log("i : "+i);
    to check if i is the value you need... 
    add it just before the if and in the check...so you can see the result.

  • Thank you, Math

    I did as you requested, and it seems to be running correctly.

    Do you know if Storyline supports this functionality?

  • Thanks for the info. I tried the \n but still no break.

    I'm displaying the variable in a text box, is that the optimal approach?