Yes, I’ve used a loop that updated the database and takes the data in by a serial set of object names with increasing numbers.
// For full API documentation, including code examples, visit Velo API Reference - Wix.com
import wixData from ‘wix-data’;
$w.onReady( function () {
//TODO: write your page related code here…
});
export function groupcheck_change(event) {
if ($w(‘#groupcheck’).checked)
$w(‘#box1’).expand();
else
$w(‘#box1’).collapse();
}
export function nonshot_change(event) {
if ($w(‘#nonshot’).checked)
$w(‘#box2’).expand();
else
$w(‘#box2’).collapse();
}
export function input3_click(event) {
}
export function page1_click(event) {
//Add your code for this event here:
}
export function input2_change(event) {
($w(‘#squadname’).text = ($w(‘#n1’).value).substring(0, 1) + ($w(‘#f1’).value).substring(0, 1)
)
}
export function button19_click(event) {
// …
for ( var X = 1; X < 8; X++) {
if ( X < 7 && ($w(‘#n’ + X).value !== ( null || “”)) && (($w(‘#c’ + X).value == ( null || “”) )
|| ($w(‘#l’ + X).value == ( null || “”)) || ($w(‘#m’ + X).value == ( null || “”))))
{ $w('#valids').text = ("Missing squad member information for - ") + ($w('#n' + X).value)
break
}
else if ($w(‘#e’).valid === false ) {$w(‘#valids’).text = “Please enter your email address”
break
}
else if (X == 7) {
var email = $w(‘#e’).value
const time1 = new Date();
for ( var y = 1; y < 12; y++) {
if ($w(‘#n’ + y).value === ( null || “”)) { }
else if (y === 1) {
var toInsert = {
“NAME”: $w(‘#n’ + y).value,
“LASTNAME”: $w(‘#f’ + y).value,
“EMAIL”: email,
“MEMBER”: $w(‘#m’ + y).value,
“LUNCH”: $w(‘#l’ + y).value,
“CLASS”: $w(‘#c’ + y).value,
“SQUAD”: $w(‘#squadname’).text,
“DATETIME”: time1}
wixData.insert("Registrants", toInsert)
.then((results) => {
let item = results; //see item below
})
. catch ((err) => {
let errorMsg = err;
});
$w('#valids').text = "Thank you for registering"
}
else {
toInsert = {
“NAME”: $w(‘#n’ + y).value,
“LASTNAME”: $w(‘#f’ + y).value,
“MEMBER”: $w(‘#m’ + y).value,
“LUNCH”: $w(‘#l’ + y).value,
“CLASS”: $w(‘#c’ + y).value,
“SQUAD”: $w(‘#squadname’).text,
“DATETIME”: time1
}
wixData.insert("Registrants", toInsert)
.then((results) => {
let item = results; //see item below
})
. catch ((err) => {
let errorMsg = err;
});
$w('#valids').text = "Thank you for registering your squad. To edit your registration, please re-submit your current details, and contact us."
};
};
break
}
}
}