Trying to create database of actors. And want to make filter on my web-site, so when someone come in he/she could filter database by age, hair color, experience and so on. For that I’m trying to use radio buttons, and button filter. Code looks like this:
let age = $w("#age").value; //want to store value of radio button "age"
let hairColor = $w("#hairColor").value; //want to store value of radio button "hair color"
//here trying to find and show results to the gallery, that already exists on web-page.
export function filterBtn_onClick() {
wixData.query("Users")
.between("age", 18)
.contains("hairColor", hairColor)
.find()
.then( (results) => {
let resultQuery = results.query;
})
.catch( (error) => {
let errorMsg = error.message;
let code = error.code;
});
}
I’m not very good at coding (at all). Know that something is wrong with it, but can’t figure it out myself. Please help.
But in drop-down it takes all the options that are written in database items. For example, I want in drop-down as options only male and female, but it gives as much male and female options as much they are in gender column in database.
Regarding the errors, it seems that the signature of your event handlers is the cause.
Instead of iTitle_keyPress($w), use either the default iTitle_keyPress(event, $w) or a simple iTitle_keyPress()
Doing iTitle_keyPress($w) means you get an event object into your $w variable, and that triggers errors.
Regarding the multiple options, you can run some logic to make sure the array of options you create contains only unique values.
For example:
The code I sent is partial.
You should put it inside your loadUsers function, in the part where you set the options of the dropdown.
Your last line, $w(’ #genderDropDown ').options = options; should stay in place, to actually set the options we created to the dropdown.
Hi Nodar!
Could you please show me your final code with Itai’s “unique function”?
'Cause I’m here trying to guess where you put it but it’s not working for me New at coding here!