Skip to main content
Inspiring
September 2, 2023
Answered

multi-line textbox into a dropdown

  • September 2, 2023
  • 2 replies
  • 910 views

Is there a way to export a multi-line textbox into a dropdown? 

 

Chat GPT gave me this, but it did not work

 

var multilineTextField = this.getField("MultilineTextField"); // Replace with the actual name of your multiline text field
var dropdownField = this.getField("YourDropdownFieldName"); // Replace with the actual name of your dropdown field

var optionsText = multilineTextField.value;
var options = optionsText.split("\n");

dropdownField.clearItems();

for (var i = 0; i < options.length; i++) {
    dropdownField.addItem(options[i]);
}

 

 

This topic has been closed for replies.
Correct answer Nesa Nurani

Use this:

var multilineTextField = this.getField("MultilineTextField").valueAsString.split(/[\r\n]+/);
this.getField("YourDropdownFieldName").clearItems();
this.getField("YourDropdownFieldName").setItems(multilineTextField);

2 replies

Nesa Nurani
Community Expert
Nesa NuraniCommunity ExpertCorrect answer
Community Expert
September 2, 2023

Use this:

var multilineTextField = this.getField("MultilineTextField").valueAsString.split(/[\r\n]+/);
this.getField("YourDropdownFieldName").clearItems();
this.getField("YourDropdownFieldName").setItems(multilineTextField);
Bernd Alheit
Community Expert
Community Expert
September 2, 2023

addItem doesn't exist in Acrobat.

Inspiring
September 2, 2023

Yea chatgpt, tried some solution, not sure if the above is possible tho