Additional to Anthony’s reply, you could take a look at one of the examples on my site…
https://russian-dima.wixsite.com/meinewebsite/switch-safe-function
import wixData from 'wix-data';
//------------------------------------ USER-DATA-INTERFACE -----------------------------------------
//var DATABASE = "Switch-Save-Function"
var DATASET = "dataset1"
//------------------------------------ USER-DATA-INTERFACE -----------------------------------------
var currentItemIndex
$w.onReady(function () {
$w("#"+DATASET).onReady( () => {
$w('#TXTmember').text="Member-"+currentItemIndex
$w('#BTNsave').onClick(()=>{
if ($w('#BTNswitch1').checked===true){$w("#"+DATASET).setFieldValue("btnStatus", true);}
else {$w("#"+DATASET).setFieldValue("btnStatus", false);}
$w("#"+DATASET).save();
})
$w('#BTNnext').onClick(()=>{console.log("NEXT")
currentItemIndex = $w("#"+DATASET).getCurrentItemIndex()+1
console.log(currentItemIndex)
$w('#TXTmember').text="Member-"+currentItemIndex
})
$w('#BTNprevious').onClick(()=>{console.log("PREVIOUS")
currentItemIndex = $w("#"+DATASET).getCurrentItemIndex()+1
console.log(currentItemIndex)
$w('#TXTmember').text="Member-"+currentItemIndex
})
})
});