Skip to main content
Jay-NH
Participant
June 21, 2024
Answered

Master Dropdown Listing

  • June 21, 2024
  • 2 replies
  • 1061 views

I have a form that has the same dropdown list on every line (over 50 of them). If I need to change an item in the list, my only option is to edit each list on every single line. Changes happen frequently. Is there really no way to have one field/list that can be the source of my dropdown lists?

This topic has been closed for replies.
Correct answer try67

Sure you can. I would do it using a (hidden) button somewhere in the vicinity of the "master" list. Say that list is called "Dropdown1" and the others are "Dropdown2" to "Dropdown50". Add a button with this code next to the first field:

 

var f = this.getField("Dropdown1");
var items = [];
for (var i=0; i<f.numItems; i++) {
	items.push(f.getItemAt(i));
}
for (var i=2; i<=50; i++) {
	this.getField("Dropdown"+i).setItems(items);
}

Update the first field's items, then click the button to update the rest of them.

Just be aware that updating the lists will clear any selections you made in any of these fields.

2 replies

try67
Community Expert
try67Community ExpertCorrect answer
Community Expert
June 21, 2024

Sure you can. I would do it using a (hidden) button somewhere in the vicinity of the "master" list. Say that list is called "Dropdown1" and the others are "Dropdown2" to "Dropdown50". Add a button with this code next to the first field:

 

var f = this.getField("Dropdown1");
var items = [];
for (var i=0; i<f.numItems; i++) {
	items.push(f.getItemAt(i));
}
for (var i=2; i<=50; i++) {
	this.getField("Dropdown"+i).setItems(items);
}

Update the first field's items, then click the button to update the rest of them.

Just be aware that updating the lists will clear any selections you made in any of these fields.

Jay-NH
Jay-NHAuthor
Participant
June 26, 2024

This seems to be working, but it is only copying to Dropdown2. Is something missing to get it to continue to copy to 3-50? I have copied and pasted the script exactly with no changes. 

Nesa Nurani
Community Expert
Community Expert
June 21, 2024

You can put list as document level JavaScript that will populate all fields.

try67
Community Expert
Community Expert
June 21, 2024

Just be aware it will reset the current selection each time it runs, so you would need to save that value first and then re-apply it later on.