What's new

How to put multiple values into an array of a dropdownlist?

With this part of code, I am trying to put all found layer names (layersData) into dropdownlist2_array, but instead of a list with names, I get one line with all names!!! Any idea what am I doing wrong? Thank you in advance!!!
var layerNames = [];
for (var i = 0; i < layersData.length; i++)
    var layerName;
    layerName = layersData[i].name;

var dropdownlist2_array = [layerNames]; 
var dropdownlist2 = panel2.add("dropdownlist", undefined, dropdownlist2_array); 
dropdownlist2.selection = -1; 
dropdownlist2.text = "Layer Name:";
Last edited:
I populate a dropdown in one of my custom script. Take a look at the code below. "arrayProjet" is an array similar to your "dropdownlist2_array"...

for (var a =0;a<arrayProjet.length;a++) {

You need to populate the dropdown in a "for" loop.

Hope this helps.