Highlighted

Convert CSV data in text field to a List in anther text field

New Here ,
Sep 11, 2020

Copy link to clipboard

Copied

Trying to Document-Level JavaScript to get comma separated values shown in one text field to show as a list in another multiline text field. 

 

Example (csv): 1SZ,ATT,FHS,GU6

Needed Result: 

1SZ

ATT

FHS

GU6

 

Current Document Level Javascript (no success):

 

function StockOptions(){
var stkOpt = this.getField("List_Options").valueAsString.split(",");
var oldValue = this.getField("Factory_Options").valueAsString;

this.getField("Factory_Options").setItems(stkOpt);
if(stkOpt.indexof(oldValue)!=-1) this.getField("Factory_Options").value = oldValue;
}

TOPICS
Acrobat SDK and JavaScript

Views

25

Likes

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

Convert CSV data in text field to a List in anther text field

New Here ,
Sep 11, 2020

Copy link to clipboard

Copied

Trying to Document-Level JavaScript to get comma separated values shown in one text field to show as a list in another multiline text field. 

 

Example (csv): 1SZ,ATT,FHS,GU6

Needed Result: 

1SZ

ATT

FHS

GU6

 

Current Document Level Javascript (no success):

 

function StockOptions(){
var stkOpt = this.getField("List_Options").valueAsString.split(",");
var oldValue = this.getField("Factory_Options").valueAsString;

this.getField("Factory_Options").setItems(stkOpt);
if(stkOpt.indexof(oldValue)!=-1) this.getField("Factory_Options").value = oldValue;
}

TOPICS
Acrobat SDK and JavaScript

Views

26

Likes

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
Sep 11, 2020 0
Most Valuable Participant ,
Sep 11, 2020

Copy link to clipboard

Copied

That code was written to populate a drop-down field, not a text field. Use this, instead:

 

this.getField("Factory_Options").value = this.getField("List_Options").valueAsString.replace(/,/g, "\n");

Likes

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
Reply
Loading...
Sep 11, 2020 0
New Here ,
Sep 11, 2020

Copy link to clipboard

Copied

that did it! Thank you

Likes

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
Reply
Loading...
Sep 11, 2020 0