Hello everyone! I got one more puzzle to solve before my website is complete…
Below you can see a picture of two selection tag groups that I have set up which auto-populate their labels and values from a database with the following code:
async function get_sTagsoptions(ITEMS, DBFIELD, sTags){
let uniqueTitles = await [...new Set(getxxx(ITEMS).flat())];
$w('#'+sTags).options = buildOptions(uniqueTitles);
function getxxx(items) {
const titlesOnly=items.map(item => item[DBFIELD]);
return [...new Set(titlesOnly)];
}
function buildOptions(item) {
return item.map(item => {
return {label:item, value:item};
});
}
}
The big question I have is: how do you alphabetically/numerically sort these? Realistically they are showing lengths of say, rope, and should be in the following order; 50’, 100’, 250’, 320.