Skip to main content
Inspiring
June 10, 2020
Answered

How to populate drop down options with values from text fields (PDF form)

  • June 10, 2020
  • 1 reply
  • 1267 views

I have a drop down field "Weight" where I want the drop down field options to be the values from various text fields.

Speficifically I have text fields Wt1, Wt2, Wt3, Wt4, and Wt5. 

The values of these text fields is determined based on other fields and user input.

I would like the drop down options that appear in "Weight" to be the values of these text fields.

I've tried something like the below. with no luck:

 

var wt1 = this.getField("Wt1").value;
var wt2 = this.getField("Wt2").value;
var wt3 = this.getField("Wt3").value;
var wt4 = this.getField("Wt4").value;
var wt5 = this.getField("Wt5").value;
this.getField("Weight").setItems([wt1,wt2,wt3,wt4,wt5]);

 

I suspect it is an easy thingto do just don't know the code or where to put it, i.e., as validation, caculation, etc.

Thanks in advance for any help on this.

This topic has been closed for replies.
Correct answer try67

Yes, this is happening because the code is constantly executing. That's the problem of doing something like that...

The solution could be to move to the code to a different type of event, or to make it only execute if the field that triggered the event (the "source") is one of those drop-downs, or to save the field's current value and then re-apply it after updating the list.

1 reply

try67
Community Expert
Community Expert
June 10, 2020

The code seems fine. What happens when you run it?

XML1979Author
Inspiring
June 11, 2020

It populates the options with those values but only the first entry Wt1 can be selected.    I can scroll through the other entries but can't select them to get them to appear.  

Where should I be placing this code do you think?   It seems to behave the same both as validation and calculation script.  

Also that is exactly how I put in the code so may be missing something.  

try67
Community Expert
try67Community ExpertCorrect answer
Community Expert
June 11, 2020

Yes, this is happening because the code is constantly executing. That's the problem of doing something like that...

The solution could be to move to the code to a different type of event, or to make it only execute if the field that triggered the event (the "source") is one of those drop-downs, or to save the field's current value and then re-apply it after updating the list.