Copy link to clipboard
Copied
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.
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.
Copy link to clipboard
Copied
The code seems fine. What happens when you run it?
Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
That makes sense.
I am going to try a work around where my drop down "Weight" has a list like choice1, choice2, choice3, etc. Then if you slelect choice2, Wt2 would be displayed in a text field next to it. If you chose choice3, then Wt3 is displayed etc. This could work out better in the long run.
I've taken to using more dummy/hidden fields once I ran into the limit on the number of lines of code. Also as a way for me to easily edit option lists, I can make them in notepad, then have a hidden/dummy drop down field populate the one the user sees. That way it is much easier to later edit the drop down option list.