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

Display multiple lines in a drop down

New Here ,
Jan 09, 2019 Jan 09, 2019

Copy link to clipboard

Copied

Hello,

I am practically new to javascript and have no idea how to code. I have 2 items in a drop down list. These 2 items are 2 separate paragraphs with about 5-6 sentences each. When I run the form and click on the drop down menu, it only shows me 1 line of text and cuts off the rest. Is there any way to code so that the whole paragraph is displayed in the drop down text box? Would greatly appreciate your help!!

TOPICS
Acrobat SDK and JavaScript

Views

1.7K

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 , Jan 09, 2019 Jan 09, 2019

Then execute this code from the Console window (or even from a button field):

this.getField("Dropdownv1").setItems(["this line is a\ntest line.", "the quick brown fox jumped\nover the lazy dog."]);

The "\n" escape character stands for "line-break", as you can see.

Votes

Translate

Translate
Community Expert ,
Jan 09, 2019 Jan 09, 2019

Copy link to clipboard

Copied

Technically it's possible, but it's an undocumented feature and it tends to be buggy, so I would not recommend doing it.

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 ,
Jan 09, 2019 Jan 09, 2019

Copy link to clipboard

Copied

I really need to get it done for my organization. Would you kindly recommend the right code/procedure to do it. Please and thanks.

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
Community Expert ,
Jan 09, 2019 Jan 09, 2019

Copy link to clipboard

Copied

OK, here's the code to achieve it:

this.getField("Dropdown1").setItems(["Item 1", "Item 2\nSecond line of item 2", "Item 3"]);

The second item in the list will have two lines.

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 ,
Jan 09, 2019 Jan 09, 2019

Copy link to clipboard

Copied

Whoa, that line may seem easy to read but I have absolutely no idea how to write it.

Could you give me an example with 2 items, for example:

  1. Option 1 of drop down: this line is a test line.
  2. Option 2 of drop down: the quick brown fox jumped over the lazy dog.

I really appreciate your help!

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
Community Expert ,
Jan 09, 2019 Jan 09, 2019

Copy link to clipboard

Copied

Where do you want the line-break(s) to be, though?

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 ,
Jan 09, 2019 Jan 09, 2019

Copy link to clipboard

Copied

  1. Option 1 of drop down: this line is a (line break) test line.
  2. Option 2 of drop down: the quick brown fox jumped (line break) over the lazy dog.

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
Community Expert ,
Jan 09, 2019 Jan 09, 2019

Copy link to clipboard

Copied

And what's the name of the drop-down field?

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 ,
Jan 09, 2019 Jan 09, 2019

Copy link to clipboard

Copied

Dropdownv1

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
Community Expert ,
Jan 09, 2019 Jan 09, 2019

Copy link to clipboard

Copied

Then execute this code from the Console window (or even from a button field):

this.getField("Dropdownv1").setItems(["this line is a\ntest line.", "the quick brown fox jumped\nover the lazy dog."]);

The "\n" escape character stands for "line-break", as you can see.

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 ,
Jan 09, 2019 Jan 09, 2019

Copy link to clipboard

Copied

Thank you!! We are almost there, the multi lines began to show up just the way I pictured. Just one problem, when I select the 2nd option from the drop down in preview mode, it automatically selects the first option and doesn't display the 2nd drop down paragraph. Any idea?

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
Community Expert ,
Jan 10, 2019 Jan 10, 2019

Copy link to clipboard

Copied

LATEST

No... As I said, it's buggy.

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