0

I am trying to create a program that will output an XSL file. Below is the code I am trying to use the '\n' does not actually create a new line, and the next value is put next to it. Am I doing something wrong?

var TheTextBox = document.getElementById("output");
        countOfAdd += 1;
        if (countOfAdd > 1){
            TheTextBox = "";
            countOfAdd = 1;
        }
        else if (countOfAdd == 1){
            //where all of the xsl output will be
            //line 1
            TheTextBox.value = TheTextBox.value + '<?xml version="1.0"?>' + '\n';
            //line 2
            TheTextBox.value = TheTextBox.value + '<!-- Sets up the stylesheet and declares the :xfa function in case you want to globalize fields -->';

EDIT: I have already tried the br HTML field but due to this being a textbox I am adding to it simply includes it in the output

EDIT 2: My example does not work already. Not sure why but the text field simply ignore the \n completely.

Dimitre Novatchev
  • 240,661
  • 26
  • 293
  • 431

3 Answers3

1

Gave up and changed it to a textarea instead of an input text field.. mistake on my end. Works now, thanks all.

-1

Check out the answer here.

You need to use the HTML entities &#13;&#10;. They create new lines rather than displaying a \n character.

Community
  • 1
  • 1
Kaspar Lee
  • 5,446
  • 4
  • 31
  • 54
-1

I see you are probably putting it in a text field.

If this is the case, try

&#13;&#10;

it should work in the text field.

Clemens Himmer
  • 1,340
  • 2
  • 13
  • 26