Hi Everyone!
Looking for some guidance, I am making a dropdown menu which will add values to a database collection but the values will be years 1900 to 2021. I would rather not input 121 items. Is there an alternative way to input many options? Not a computer programmer here therefore hoping for something built in…
Best,
KG
KG,
Without coding, you’d have to do it manually, which you’re trying to avoid.
$w.onReady(function () {
let Options = [], Option = {}, year = "";
for (var i = 1900; i <= 2021; i++) {
year = i.toString();
Option = {"label": year, "value": year};
Options.push(Option);
}
$w("#dropdown1").options = Options;
});
I appreciate the response and the code. I’ll give it a shot - where do I input this?
Sounds like you have zero familiarity with all of this. At the bottom of each page, you will find the way to access the code page for that particular page. By default, there is an onReady function on every page. Just override that with this code. Also, your dropdown may very well be named something other than “dropdown1”. If so, you will need to change it to its real name. The pound sign is necessary; keep that.
Super! It worked. Greatly appreciated