Skip to main content
July 14, 2016
Question

Adding line breaks to a multi-line field using a custom format script

  • July 14, 2016
  • 1 reply
  • 7695 views

.Hi Everyone,

I'm creating a PDF that generates a report, but I'm stuck on how to automatically format the final text field, specifically to get line breaks before each bullet point.

This is how the report works - Depending on the answer given to a question, the PDF populates 2 fields; one with the positive elements and another with the ways to improve. All the positive answers are then gathered into a text field (reportPositiveFinal) using a simple JavaScript. When a 'Generate Report' button is hit, it triggers a JavaScript to transfer the positive text into the positive final report field (repP), as a string.

The problem - The text that comes out is fine, but there is no formatting. I want to have the text appear as a bulleted list; with a bullet beginning the line and a line break at the end of item.

Partial Solution - The closest I think I got to an answer was by using a custom format script using a regular expression to identify the bullet and replace it with a bullet with a line break before it, but I tried and failed to get it to work. (I'm still not entirely sure what a regular expression is!)

if (event.value!="• ")

event.value=event.value.replace(<br/>"• ")

My coding level is minimal, so I'm way out of my depth.

Is this the right idea? If not, what is the way to go?

Thanks!

This topic has been closed for replies.

1 reply

Bernd Alheit
Community Expert
Community Expert
July 14, 2016

Form fields don't use HTML code. Try '\r' or '\n'.

July 14, 2016

I tried replacing the <br/> in the code with \r and \n (as below) but both gave the error "Syntax Error: illegal character"

if (event.value!="• ")

event.value=event.value.replace(\r "•")

Any advice?

Bernd Alheit
Community Expert
Community Expert
July 14, 2016

Look at the documentation of 'replace'.