Hey Wixers,
I am so hard looing for a solution for : People are checking what they offer in checkboxgroup those values get saved in the database when i display them it also show me the ones that are not ticked but i want only to display the ones that have been ticked
Ass you can see the following code tells me map undefined but i tried everything no solution yet
import wixData from ‘wix-data’ ;
export function dynamicDataset_ready() {
let item = $w( “#dynamicDataset” ).getCurrentItem;
// substitute your field name storing the tags
let chosenValues = item.wellness;
let newOptions = buildOptions(chosenValues);
$w( “#checkboxGroup5” ).options = newOptions;
// if you want them all checked?
let indices = buildSelectedIndices(chosenValues);
$w( “#checkboxGroup5” ).selectedIndices = indices;
}
function buildOptions(chosenValues) {
return chosenValues.map((curr) => {
return { label: curr.toString(), value: curr };
});
}
function buildSelectedIndices(chosenValues) {
let selIndices = ;
for ( var i = 0 ; i < chosenValues.length; i++) {
selIndices.push(i);
}
return selIndices;
}