Skip to main content
Participant
August 17, 2021
Answered

Splitting a multiline text field by '\n' is giving me a terribly hard time

  • August 17, 2021
  • 1 reply
  • 779 views

I am trying to take the contents of a multi-line text field and split them into an array by the newline escape character but its not working at all.

For reference im trying to make it so that my boss can edit the staff members on a staffing form (as people are hired) by editing the text field, they would then be included in drop down menus.

 

var dropdownexample = this.getField("dropdownmenu")
var stafflist = this.getField("stafflist")
var arr = stafflist.value.split(/\n/);
dropdownexample.setItems(arr);

 

I am just confused why its not picking up the newline character... Im more accustomed to python where this isn't usually a problem. I would greatly appreciate any help y'all have to offer. Thanks!

This topic has been closed for replies.
Correct answer try67

Probably because the line-break character in multiline fields is "\r", not "\n"...

1 reply

try67
Community Expert
try67Community ExpertCorrect answer
Community Expert
August 17, 2021

Probably because the line-break character in multiline fields is "\r", not "\n"...

Participant
August 18, 2021

ah yes this worked!