Appending a new line to a Captivate variable in Javascript
I have a responsive project that uses a text entry box for the user to make notes whilst progressing through the project. What I would like to do is append some text to this depending on the outcome of various interactions.
I am using Javascript for one interaction and can update the variable used by the TEB without an issue. However, I am having problems adding a new line from within Javascript. I have searched for previous discussions here and online. I have tried adding the following line in the Javascript to update the TEB variable using the escape sequence "\n" for a new line, as specified in the MDN docs:
v_teb_notes=v_teb_notes + "\nMy heading\nMy text to add.";
I believe that "\n" should add the new line, but when I run this the code fails. In the browser console I see the error "SyntaxError: '' string literal contains an unescaped line break".
When I remove the "\n" the JS executes, but no line breaks are added.
v_teb_notes=v_teb_notes + "My heading My text to add.";
I am not sure what I am doing wrong. I have tried various options based on other threads here without success, including using the Scrolling Text Widget. I wonder if Captivate is doing something odd to the JS. This post from over ten years ago says that Captivate strips "\n" in Advanced Actions. I hoped this would not happen from JS, but since the JS is executed as an action maybe it does. This would explain the browser error. If so, is there a work around?
On a similar note, I cannot find a way to add a new line to a Captivate variable either. One thread recommended using HTML e.g. adding "<br/>" to the variable value, but that doesn't work.
Hopefully someone can help!
