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

Display multiple lines in a drop down

New Here ,
Jan 09, 2019 Jan 09, 2019

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
3.2K
Translate
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.

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

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

Translate
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

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

Translate
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

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.

Translate
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

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!

Translate
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

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

Translate
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
  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.
Translate
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

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

Translate
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

Dropdownv1

Translate
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

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.

Translate
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

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?

Translate
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
LATEST

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

Translate
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