Dependent Dropdowns with form submission.

Hey,

I try to make a form to upload images to one database called: VillagePic.
in this form: https://www.kfarim.co.il/copy-3-of-admin-2
I succedded to do the Dependent Dropdowns as I read in this post:
https://www.wix.com/code/home/forum/community-discussion/dependent-dropdown-1

but now i don’t know how to connect the filter results to the form…
because when i sent the form, the value of the dropdowns doesn’t show on my VillagePic database.
I’m guessing it’s because the dropdowns are references.

Please Help :slight_smile:

@yisrael-wix

So have you connected the dropdowns to the data collection as a reference field they should be stored in the submission as well.

1 Like

Hi @andreas-kviby ,

Thanks for the quick respond.
when i connect the dropdown to the data collection i can’t use the Connect a List option and the code don’t work.

Any chance you know what is the problem?

Thanks :slight_smile:

this my code:

import wixData from ‘wix-data’;

export function dropdown2_change(event, $W) {
villagefilter ();
}

async function villagefilter() {
// retrieve all items from the Category dropdown
const categories = ( await $w(“#dataset2”).getItems(0, 20)).items

// get ID of currently selected Category
const selectedCategoryId = categories[$w(“#dropdown2”).selectedIndex]._id

$w(‘#dataset3’).setFilter(
wixData.filter().eq(“dest”, selectedCategoryId)
)
}

Ok so let’s keep the dropdowns your way and click each dropdown in the properties panel and add a onChange event. Inside that event add

$w("#myDataset").setFieldValue("fieldkey in your data collection", $w("#dropdown id here").value);

So whenever someone changes the dropdowns it will set the value to your field using that code above and then when you save the dataset this values will also be saved.

1 Like

Thanks Andreas.
stupid question… what does #myDataset refer to?

I tried to do it myself but didn’t succeed.
@andreas-kviby a question
If I add a drop down list that connected to the VillagePic dataset and set it on hide on load .
is it possible to set the value of the now drop down to an another one?