Add a line break in Javascript | XM Community
Skip to main content
Hello,



I am trying to auto fill a text box in a question using Javascript. I want it to appear in a sequential format but I cannot seem to add a line break in the text I want to add. I tried using '\\n', '<'br'>' and '<'br/' >' but nothing is working. How can I accomplish this?



Thanks
Make sure your text input question is the Essay type so that it is a `<textarea>`. `<input>` doesn't support line breaks, but `<textarea>` does. Then use \\n:

```

Qualtrics.SurveyEngine.addOnload(function() {

jQuery("#"+this.questionId+" .InputText").val("line1\\nline2");

});

```
@TomG thank you for your response. I would never have guessed the question type would be the issue.

Leave a Reply