Display multiple lines in a drop down

New Here ,
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!!

Most Valuable Participant
Correct answer by try67 | Most Valuable Participant

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.

TOPICS
Acrobat SDK and JavaScript, Macintosh

Views

200

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

Display multiple lines in a drop down

New Here ,
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!!

Most Valuable Participant
Correct answer by try67 | Most Valuable Participant

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.

TOPICS
Acrobat SDK and JavaScript, Macintosh

Views

201

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
Jan 09, 2019 0
Most Valuable Participant ,
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.

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...
Jan 09, 2019 0
New Here ,
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.

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...
Jan 09, 2019 0
Most Valuable Participant ,
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.

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...
Jan 09, 2019 2
New Here ,
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!

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...
Jan 09, 2019 0
Most Valuable Participant ,
Jan 09, 2019

Copy link to clipboard

Copied

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

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...
Jan 09, 2019 0
New Here ,
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.

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...
Jan 09, 2019 0
Most Valuable Participant ,
Jan 09, 2019

Copy link to clipboard

Copied

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

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...
Jan 09, 2019 0
New Here ,
Jan 09, 2019

Copy link to clipboard

Copied

Dropdownv1

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...
Jan 09, 2019 0
Most Valuable Participant ,
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.

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...
Jan 09, 2019 2
New Here ,
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?

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...
Jan 09, 2019 0
try67 LATEST
Most Valuable Participant ,
Jan 10, 2019

Copy link to clipboard

Copied

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

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...
Jan 10, 2019 0