Skip to main content
Participating Frequently
January 9, 2019
Answered

Display multiple lines in a drop down

  • January 9, 2019
  • 1 reply
  • 3032 views

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!!

This topic has been closed for replies.
Correct answer try67

Dropdownv1


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.

1 reply

try67
Community Expert
Community Expert
January 9, 2019

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

Participating Frequently
January 9, 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.

try67
Community Expert
Community Expert
January 9, 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.