Skip to main content
Inspiring
Sep 6, 2020 11:55 AM UTC
Answered

Javascript new line

New Line: \n

Empty Line (row): \n\n

Half Empty Line (row): ?

Is there such thing?

This topic is closed to new replies. Start a new post to keep the conversation going.
try67
try67Correct answer
Community Expert
Sep 6, 2020 2:48 PM UTC

You can use richValue to set empty text with whatever size you want your empty line to be.

try adapt this to your code:

var spans = new Array();
spans[0] = new Object();
spans[0].text = " \n";
spans[0].textSize = 5;
event.richValue = spans;}


For some reason I thought that wouldn't change the height of the line, but it does... The full code would be:

var spans = new Array();
spans[0] = new Object();
spans[0].text = "Line 1\n";
spans[0].textSize = 10;
spans[1] = new Object();
spans[1].text = "\n";
spans[1].textSize = 5; // change this value to change the distance between the two lines
spans[2] = new Object();
spans[2].text = "Line 2";
spans[2].textSize = 10;

this.getField("Text1").richValue = spans;

 

 

9 replies

Bernd Alheit
Community Expert
Community Expert
Sep 6, 2020 1:14 PM UTC

Is this for form text fields?

Translate
blazbAuthor
Inspiring
Sep 6, 2020 1:28 PM UTC

Yes

Translate
Nesa Nurani
Community Expert
Community Expert
Sep 6, 2020 2:27 PM UTC

You can use richValue to set empty text with whatever size you want your empty line to be.

try adapt this to your code:

var spans = new Array();
spans[0] = new Object();
spans[0].text = " \n";
spans[0].textSize = 5;
event.richValue = spans;}

Translate
try67
Community Expert
Community Expert
Sep 6, 2020 12:06 PM UTC

What is an "half empty line"? Please explain what you mean.

Translate
blazbAuthor
Inspiring
Sep 6, 2020 12:24 PM UTC

Lets say if \n\n is 10px height empty line between rows, is there code that does 5px height empty line ?

Translate
try67
Community Expert
Community Expert
Sep 6, 2020 12:36 PM UTC

Ah, I see. No, that's not possible with a script.

Translate