Instead of writing it all out, I would need to do it many times on my page and I know there is an easier way. I have been trying to find a way to do it for a few hours and my brain hurts.
Thanks.
I should have stated this before, I am getting tierss from a backend fetch call so I don’t think your solution will work. I am looking to just use a loop on the page to do it untill all the results are entered in the dropdown, the number of results changes all the time.
@shawn-johnson
Okay. Not sure how to push the values directly to the dropdown. The only way I can think of is to create an array and push the values from tierss to it with a loop. Then use the newArray options for the dropdown. Hope this helps. If not, then hope someone else can provide a better answer. Good luck.
$w.onReady(function () {
let newArray = [];
for (var i = 0; i < tierrs.length; i++) {
newArray.push(
{"label": "" + tierrs[l], "value": l.toString()}
);
}
$w("#dropTier").options = newArray;
})
@shawn-johnson Marcia’s answer will work…probably. I think your explanation is a little vague and it’s hard to tell if you are using placeholders and where. Also, I think you can have numerical values, but only string labels for dropdowns.
A couple of minor fixes to Marcia’s code:
let newArray = [];
for (let i = 0; i < tierrs.length; i++) {
newArray.push({"label": tierrs[i], "value": i});
if (i === tierrs.length - 1) $w("#dropTier").options = newArray;
}