Skip to main content
Inspiring
May 7, 2020
Answered

About the code to write to the drop-down list field.

  • May 7, 2020
  • 2 replies
  • 1323 views

I have set the items in the dropdown list as follows.

 

var l = this.getField("Dropdown1");
l.setItems(["One", "Two", "Three"]);

 

This will certainly show "One", "Two", "Three" in the drop down list.
However, when actually using it, for some reason only "One" can be selected.

Even if I select "Two", "One" is displayed.

 

I created a button for trial and wrote the code there.
In this case, it worked as planned.

 

Why can't I just write the code directly in the drop-down list?
Is it possible to achieve the goal without creating a new button?

This topic has been closed for replies.
Correct answer try67

This kind of code only needs to execute once, or when the options change. When you use setItems it resets the field to the default value (the first item in the list), which is probably what is happening in your case.

2 replies

try67
Community Expert
try67Community ExpertCorrect answer
Community Expert
May 8, 2020

This kind of code only needs to execute once, or when the options change. When you use setItems it resets the field to the default value (the first item in the list), which is probably what is happening in your case.

Inspiring
May 9, 2020

The point is that what I want to do is impossible. I can understand what you say. Thank you very much.

try67
Community Expert
Community Expert
May 9, 2020

I don't know what you want to do, but that's not what I said...

Bernd Alheit
Community Expert
Community Expert
May 8, 2020

Where in the dropdown list does you use the script?

Inspiring
May 9, 2020

Where to enter the formula on the Options tab of the drop-down list field.