I want to filter a database using dropdowns. I have a dropdown that has the title values, and for this no problem. But i have a second dropdown that has the fields values. Is there a way i can make it variable ? (when the selected value in dropdwon2 is mercedesClassV, filter the already filtered dataset to retrieve the right price) !
// API Reference: https://www.wix.com/velo/reference/api-overview/introduction
// “Hello, World!” Example: https://learn-code.wix.com/en/article/1-hello-world
import wixData from 'wix-data';
$w.onReady(function () {
$w("#input1").value = "Paris"
});
export function button10_click(event) {
Estimate()
}
export function Reset() {
$w("#group1").hide()
$w("#dataset1").setFilter(wixData.filter())
}
export function Estimate() {
$w("#dataset1").setFilter(wixData.filter().contains('title', $w("#dropdown2").value)).then(() => {
let itemObj = $w("#dataset1").getCurrentItem()
let field = $w("#dropdown1").value
$w("#text30").text = itemObj.field
$w("#group1").show()
})
}
here i tried to set the field value to the “field” name, but i think that putting “field” after “itemObj” will just look for the “field” field in dataset (which doesn’t exists)
site web : ACCUEIL | My Site 2 (wixsite.com)
May be the fabulous @Yisrael (Wix) of the awesome @russian-dima have answers !