dropdown1 is populated from a field1 in a collection1 referenced into the main collection2
dropdown2 is populated from a field the main collection2 and needs to submit data
I need to filter dropdown2 to a limited set of items from the dropdown1 item choice
collection1 has the field1 and field2 that correlate with a field2r in collection2, field2r is also the referencing field, so no subfields are required.
I managed to get the code queens conditional filtering with two unique dropdowns to work fine. However this will not allow me to submit data as i need to add the reference field and not the collection1 field.
Can this work with the wix code framework or should i not use reference fields and use some other paradigm?
If it can work how can this be achieved is there a guide on how to do this?
Thanx for your quick reply, is the airport name = collection2FieldKey as I am getting a dropdown populated with the _id instead of the reference label.
Hi Mike,
Yes I couldnt get the code you provided to populate the dropdown2 at all, so i tried making a search tesybox to replace dropdown1 instead and at least it populates the dropdown2 with the speciesData reference field’s id, it makes the id the label so i am thinking it is something wrong with the mapping. I did a console log and i can see only the main collection reference fields as IDs along with the normal text fields.
note:
none of the dropdowns are connected to a dataset though i have the Avian_Data collection linked on the page its not being used by the inputs.
//species
export function inputSpecies_change(event) {
//Add your code for this event here:
wixData.query(“Avian_Data”)
.contains(“speciesData”, $w(“#inputSpecies”).value)
.limit(1000)
.ascending(“speciesData”)
.find()
.then(results => { const uniqueTitles = getUniqueTitles(results.items);
console.log(results);
$w(“#dropdownTaxonSpecies”).options = buildOptions(uniqueTitles);
});
//we remove all duplicate results function getUniqueTitles(items) {
const titlesOnly = items.map(item => item.speciesData); return [… new Set(titlesOnly)];
@mikemoynihan99 sorry, to confuse, no i changed to just searching on a textbox as i couldnt get any results from using a dropdown to search for a match.
@mikemoynihan99 oh i get just a list of Ids it varies depending on what i type, the textbox is findingmatches based on the letters i type, however the matches seem to be inside the ids.
hi, so i am trying to use the reference collection so i can use the same drop down to add new entries. Maybe I am not using reference collections how they are supposed to be used?