• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

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

New Here ,
Aug 17, 2021 Aug 17, 2021

Copy link to clipboard

Copied

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!

TOPICS
Acrobat SDK and JavaScript , Windows

Views

361

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Community Expert , Aug 17, 2021 Aug 17, 2021

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

Votes

Translate

Translate
Community Expert ,
Aug 17, 2021 Aug 17, 2021

Copy link to clipboard

Copied

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

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Aug 17, 2021 Aug 17, 2021

Copy link to clipboard

Copied

LATEST

ah yes this worked!

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines