Hi, so I’m fairly new to coding and still learning A LOT. So please don’t judge me if my code looks bad.
I’m having an issue with trying to use a for loop that will run through and fill the elements on the page. What I’m trying to do is have a for loop run though and search the database for the order that I’ve put the modules in (e.g. 1-30). This should then return the name of the module. Once the module name has been found I would like it to fill in the textbox that goes with that name (e.g. textBox1, textBox2, textBox3 exc.) I’m trying to use i to fill in the associated textbox number but I can’t seem to figure it out.
I’m not sure how to get this to work or if this is even the right way to go about this. I would assume I should use a for loop so I’m not repeating this 30 times. Any help or advice would be much appreciated!
for (var i = 1; i <= 30; i++) {
wixData.query("SiteModules")
.eq("Order", i)
.find()
.then((results) => {
let moduleName = results.items[0].moduleName;
$w("#moduleName" + i).text = moduleName;
})
}