Hey, please could someone tell me where I am going wrong with my code? I need my drop down box to show all countries in A-Z and remove duplicates. Thanks!
import wixData from “wix-data”;
$w.onReady( function () {
$w(" #button1 “).target = “_self”;
$w(” #dataset1 “).onReady( () => {
let options = $w(” #iContinent “).options;
options.sort( function (a, b) {
let labelA = a.label.toUpperCase();
let labelB = b.label.toUpperCase();
if (labelA < labelB) { return -1;
}
if (labelA > labelB) { return 1;
} return 0;
});
$w(” #iContinent ").options = options;
})
})
$w.onReady(() => {
loadContinents();
});
let lastFilterTitle;
let lastFilterContinent;
let debounceTimer;
export function iTitle_keyPress(event, $w) {
if (debounceTimer) {
clearTimeout(debounceTimer);
debounceTimer = undefined;
} debounceTimer = setTimeout(() => {
I can see that the code is copied from an example so you might want to check for correct ids.
The below code will allow you to display only the unique values provided that you have set the correct database name, database field keys & the id of the dropdown.
I’ve triple checked, all connected correctly. The issue is the code works perfectly in the editor, everything working in preview and shows correctly.
The second I try on the live site (everything still works) however the duplicates on the dropdown are back (even though they are not there in preview mode!!)
Pulling my hair out here, I’m sure its a Wix error!
I tried but it just shows the label ‘All Countries’ and doesn’t show any other options now, I’ve double checked it all so not sure where its going wrong, maybe because its linked with another search box?