We have a client that runs a band rental business. They have a super large custom rental form we are building now and I am having an issue building some of the dropdowns.
We have a dropdown for the grade of a student and the options they can choose from is determined from which school they choose. In a database we have all of the schools and then the low grade and the highest grade. I built a for loop that seems to work with all numbers under 9 which is super odd. If anyone selects a highschool it does not populate.
export function populateGrade (parameter) {
wixData.query("Schools")
.eq('schoolName', $w("#iptSchool").value)
.find()
.then(results => {
let uniqueList = createUniqueListGrade(results.items);
$w("#iptGradeLevel").options = buildOptionsGrade(uniqueList);
})
function createUniqueListGrade (items) {
let lowGrade = items.map(item => item.lowGrade)
let highGrade = items.map(item => item.highGrade)
var gradesArray = [];
for (let i = lowGrade; i <= highGrade; i++) {
gradesArray.push(i.toString());
console.log(gradesArray);
}
return[...new Set(gradesArray)];
}
function buildOptionsGrade (uniqueList) {
let uniqueListFinal = uniqueList.map(curr => { return {label:curr, value:curr}; });
uniqueListFinal.push({"label": "Other", "value": "Other"});
return uniqueListFinal;
}
Damn! You are right --> i am stupid xD
Is all of this running in the backend?
export function populateGrade(parameter){.........