Hi guys,
I have built a form that collects data about damage to our company vehicles, allowing users to add descriptions and an image for each record. These can then be recalled on the same page by selecting the vehicle ID, and the user can review all the existing submissions.
Thankfully, damage is not permanent, so once it’s repaired, I would like to be able to delete that row in the collection, by selecting the correct record on the webpage.
I have done a lot of looking around to see if there’s a simple way to do this but they all seem to involve code and I have zero coding background - I understand many of the words, but none of the meaning.
What I have found so far:
export function btnDelAll_click ( event ) {
// This function was added from the Properties & Events panel. To learn more, visit Velo: Working with the Properties & Events Panel | Help Center | Wix.com
// Add your code for this event here:
// Create a function to delete the current rows in the book dataset
async function deleteAll () {
// Continue the deletion until the dataset has no row
**while** ( $w ( "#dataset1" ). getCurrentItem () ) {
**await** $w ( "#dataset1" ). remove ();
}
}
// Delete rows after book dataset loads any data
$w ( ‘#dataset1’ ). onReady ( deleteAll );
// Refresh to load more data into dataset
$w ( ‘#dataset1’ ). refresh ();
and
$w ( “#dataset1” ). onReady ( async () => { if ( $w ( “#dataset1” ). getCurrentItem ()){
await $w ( “#dataset1” ). remove ();
while ( $w ( “#dataset1” ). hasNext ()){
await $w ( “#dataset1” ). next ();
await $w ( “#dataset1” ). remove ();
}
}
});
The first code snippet works, but it deletes entries one-by-one until they’re all gone - this much I understand, so is wholly unsuitable for my purposes!
I’d be really grateful if someone could help me get this button working.
Many thanks.
Image for reference: