Hi,
I think I have what I need here to filter two dropdowns to display a filtered choice from a referenced collection “Species”. However when I try to submit the fields for the referenced collection species are missing. If I connect the dropdown2 to the main collection, it just resets my dropdown2 selection.
Do I create a collection object that matches the entire row in my reference collection? Do I submit the selected dropdown item or object in the submit button event or do I simply populate the dropdown “#dropdownTaxonSpecies” and that will behave the same as connecting the reference collection and the reference fieldKey. Or do I need to create a new database ID and add it to an object and submit that?
function uniqueDropDown2() {
wixData.query("Species")
.contains("familyCommonName", $w("#dropdownFamCommName").value)
.limit(1000)
.find()
.then(results => {
const uniqueTitles = getUniqueTitles(results.items);
console.log(uniqueTitles);
$w(“#dropdownTaxonSpecies”).options = buildOptions(uniqueTitles);
});
function getUniqueTitles(items) {
const titlesOnly = items.map(item => item.taxonName);
return [… new Set(titlesOnly)];
}
function buildOptions(uniqueList) {
return uniqueList.map(curr => {
return { label: curr, value: curr };
});
}
}