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!!
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.
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.
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.
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.
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:
I really appreciate your help!
Copy link to clipboard
Copied
Where do you want the line-break(s) to be, though?
Copy link to clipboard
Copied
Copy link to clipboard
Copied
And what's the name of the drop-down field?
Copy link to clipboard
Copied
Dropdownv1
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.
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?
Copy link to clipboard
Copied
No... As I said, it's buggy.