Copy link to clipboard
Copied
I need a solution in place to split a multi line field at a certain point and fill the remaining split text into another field. I have three multi-line fields named Field 1, Field 2, and Field 3. I should say that data is not typed into these fields but rather is populated via a series of functions that grabs data from the other form fields and summarizes results in Field 1. If data does not fit in Field 1 I would like the text to overflow into Field 2..and so on. I already have the code to populate the fields.
I had the idea that the easiest way to do this count the number of paragraph returns and then split when a certain number is reached. I know how to count the returns but not sure how to implement splitting overflow..
So for example, if I have this code:
var count = 0;
var s = getField("Field1").valueAsString;
for (var i = 0; i < s.length; i++) {
if (s === "\r") count += 1;
}
....and I want to split the text at 50 returns.. then fill Field2.
Can this be done? Maybe there is an easier way than counting returns?
Thanks in advance.
You can use the slice method to return part of an array. See: JavaScript Array slice() Method
Copy link to clipboard
Copied
You can use the slice method to return part of an array. See: JavaScript Array slice() Method
Copy link to clipboard
Copied
Here's an article on almost this exact topic.
https://acrobatusers.com/tutorials/splitting-and-rebuilding-strings