Is it possible to change the following if function into a loop of some kind? My knowledge of loops is not very good, but I know that they exist and can simplify code that can be quite long when you have multiple ifs.
My code is...
export function r1Mark_click() {
let QUIZID = +($w('#quizID').text);
wixData.query("Players")
.skip(1)
.eq("gameId", QUIZID)
.ascending("_createdName")
.find()
.then((results) => {
console.log(results.items);
$w('#table1q1').rows = results.items;
$w('#table1q2').rows = results.items;
$w('#table1q3').rows = results.items;
$w('#table1q4').rows = results.items;
$w('#table1q5').rows = results.items;
$w('#table1q6').rows = results.items;
$w('#table1q7').rows = results.items;
$w('#table1q8').rows = results.items;
$w('#table1q9').rows = results.items;
$w('#table1q10').rows = results.items;
});
if (+($w("#teamsCount").text) < 1) {
$w("#1q1ptsA").collapse();
$w("#1q1ptsB").collapse();
$w("#1q1ptsC").collapse();
$w("#1q1ptsD").collapse();
$w("#1q1ptsE").collapse();
$w("#1q1ptsF").collapse();
$w("#1q1ptsG").collapse();
$w("#1q1ptsH").collapse();
$w("#1q1ptsI").collapse();
$w("#1q1ptsJ").collapse();
$w("#1q1ptsK").collapse();
$w("#1q1ptsL").collapse();
$w("#1q1ptsM").collapse();
$w("#1q1ptsN").collapse();
$w("#1q1ptsO").collapse();
} else {
if (+($w("#teamsCount").text) < 2) {
$w("#1q1ptsB").collapse();
$w("#1q1ptsC").collapse();
$w("#1q1ptsD").collapse();
$w("#1q1ptsE").collapse();
$w("#1q1ptsF").collapse();
$w("#1q1ptsG").collapse();
$w("#1q1ptsH").collapse();
$w("#1q1ptsI").collapse();
$w("#1q1ptsJ").collapse();
$w("#1q1ptsK").collapse();
$w("#1q1ptsL").collapse();
$w("#1q1ptsM").collapse();
$w("#1q1ptsN").collapse();
$w("#1q1ptsO").collapse();
} else {
if (+($w("#teamsCount").text) < 3) {
$w("#1q1ptsC").collapse();
$w("#1q1ptsD").collapse();
$w("#1q1ptsE").collapse();
$w("#1q1ptsF").collapse();
$w("#1q1ptsG").collapse();
$w("#1q1ptsH").collapse();
$w("#1q1ptsI").collapse();
$w("#1q1ptsJ").collapse();
$w("#1q1ptsK").collapse();
$w("#1q1ptsL").collapse();
$w("#1q1ptsM").collapse();
$w("#1q1ptsN").collapse();
$w("#1q1ptsO").collapse();
} else {
if (+($w("#teamsCount").text) < 4) {
$w("#1q1ptsD").collapse();
$w("#1q1ptsE").collapse();
$w("#1q1ptsF").collapse();
$w("#1q1ptsG").collapse();
$w("#1q1ptsH").collapse();
$w("#1q1ptsI").collapse();
$w("#1q1ptsJ").collapse();
$w("#1q1ptsK").collapse();
$w("#1q1ptsL").collapse();
$w("#1q1ptsM").collapse();
$w("#1q1ptsN").collapse();
$w("#1q1ptsO").collapse();
} else {
if (+($w("#teamsCount").text) < 5) {
$w("#1q1ptsE").collapse();
$w("#1q1ptsF").collapse();
$w("#1q1ptsG").collapse();
$w("#1q1ptsH").collapse();
$w("#1q1ptsI").collapse();
$w("#1q1ptsJ").collapse();
$w("#1q1ptsK").collapse();
$w("#1q1ptsL").collapse();
$w("#1q1ptsM").collapse();
$w("#1q1ptsN").collapse();
$w("#1q1ptsO").collapse();
} else {
if (+($w("#teamsCount").text) < 6) {
$w("#1q1ptsF").collapse();
$w("#1q1ptsG").collapse();
$w("#1q1ptsH").collapse();
$w("#1q1ptsI").collapse();
$w("#1q1ptsJ").collapse();
$w("#1q1ptsK").collapse();
$w("#1q1ptsL").collapse();
$w("#1q1ptsM").collapse();
$w("#1q1ptsN").collapse();
$w("#1q1ptsO").collapse();
} else {
if (+($w("#teamsCount").text) < 7) {
$w("#1q1ptsG").collapse();
$w("#1q1ptsH").collapse();
$w("#1q1ptsI").collapse();
$w("#1q1ptsJ").collapse();
$w("#1q1ptsK").collapse();
$w("#1q1ptsL").collapse();
$w("#1q1ptsM").collapse();
$w("#1q1ptsN").collapse();
$w("#1q1ptsO").collapse();
} else {
if (+($w("#teamsCount").text) < 8) {
$w("#1q1ptsH").collapse();
$w("#1q1ptsI").collapse();
$w("#1q1ptsJ").collapse();
$w("#1q1ptsK").collapse();
$w("#1q1ptsL").collapse();
$w("#1q1ptsM").collapse();
$w("#1q1ptsN").collapse();
$w("#1q1ptsO").collapse();
} else {
if (+($w("#teamsCount").text) < 9) {
$w("#1q1ptsI").collapse();
$w("#1q1ptsJ").collapse();
$w("#1q1ptsK").collapse();
$w("#1q1ptsL").collapse();
$w("#1q1ptsM").collapse();
$w("#1q1ptsN").collapse();
$w("#1q1ptsO").collapse();
} else {
if (+($w("#teamsCount").text) < 10) {
$w("#1q1ptsJ").collapse();
$w("#1q1ptsK").collapse();
$w("#1q1ptsL").collapse();
$w("#1q1ptsM").collapse();
$w("#1q1ptsN").collapse();
$w("#1q1ptsO").collapse();
} else {
if (+($w("#teamsCount").text) < 11) {
$w("#1q1ptsK").collapse();
$w("#1q1ptsL").collapse();
$w("#1q1ptsM").collapse();
$w("#1q1ptsN").collapse();
$w("#1q1ptsO").collapse();
} else {
if (+($w("#teamsCount").text) < 12) {
$w("#1q1ptsL").collapse();
$w("#1q1ptsM").collapse();
$w("#1q1ptsN").collapse();
$w("#1q1ptsO").collapse();
} else {
if (+($w("#teamsCount").text) < 13) {
$w("#1q1ptsM").collapse();
$w("#1q1ptsN").collapse();
$w("#1q1ptsO").collapse();
} else {
if (+($w("#teamsCount").text) < 14) {
$w("#1q1ptsN").collapse();
$w("#1q1ptsO").collapse();
} else {
if (+($w("#teamsCount").text) < 15) {
$w("#1q1ptsO").collapse();
} else {
$w("#1q1ptsO").expand();
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
To summarise, when the number of teams is 1, the code ensures that only the first input box is shown. If there are 2, the code will only show the first 2, etc.
If you could write the loop code that would be great! : ) (If it is possible)