I have 3 dropdown menus,where people can sort location(country,state,city)
After selecting the location there is a search button that should work on click and According the location selected would like to display the results on another page,in a repeater.
I don't know/can't trigger the on click button.
The dropdown filters correctly.Once filtering has finished how can i make the search button to work?Thank you
import wixData from 'wix-data'; import {local} from 'wix-storage'; import wixLocation from 'wix-location'; $w.onReady(function () {uniqueDropDown1(); }); function uniqueDropDown1 (){ wixData.query("Companydetails") .limit(1000) .find() .then(results => { const uniqueTitles = getUniqueTitles(results.items); $w("#selectProfessional").options = buildOptions(uniqueTitles); }); function getUniqueTitles(items) { const titlesOnly = items.map(item => item.category); return [...new Set(titlesOnly)];} function buildOptions(uniqueList) { return uniqueList.map(curr => { return {label:curr, value:curr}; });}} export function selectProfessional_change(event, $w) { uniqueDropDown2(); $w("#selectCountry").enable();} function uniqueDropDown2 (){ wixData.query("Companydetails") .contains("category", $w("#selectProfessional").value) .limit(1000) .find() .then(results => { const uniqueTitles = getUniqueTitles(results.items); $w("#selectCountry").options = buildOptions(uniqueTitles); }); function getUniqueTitles(items) { const titlesOnly = items.map(item => item.country); return [...new Set(titlesOnly)];} function buildOptions(uniqueList) { return uniqueList.map(curr => { return {label:curr, value:curr}; });}} export function selectCountry_change(event, $w) { uniqueDropDown3(); $w("#selectprovince").enable();} function uniqueDropDown3 (){ wixData.query("Companydetails") .contains("country", $w("#selectCountry").value) .limit(1000) .find() .then(results => { const uniqueTitles = getUniqueTitles(results.items); $w("#selectprovince").options = buildOptions(uniqueTitles); }); function getUniqueTitles(items) { const titlesOnly = items.map(item => item.province); return [...new Set(titlesOnly)]; } function buildOptions(uniqueList) { return uniqueList.map(curr => { return {label:curr, value:curr}; });}} export function selectprovince_change(event, $w) { uniqueDropDown3(); $w("#selectTown").enable();} function uniqueDropDown4 (){ wixData.query("Companydetails") .contains("province", $w("#selectprovince").value) .limit(1000) .find() .then(results => { const uniqueTitles = getUniqueTitles(results.items); $w("#selectTown").options = buildOptions(uniqueTitles); }); function getUniqueTitles(items) { const titlesOnly = items.map(item => item.town); return [...new Set(titlesOnly)]; } function buildOptions(uniqueList) { return uniqueList.map(curr => { return {label:curr, value:curr}; }); } } export function searchButton_click() { //search button code? let word = $w("#selectProfessional").value; let word1 = $w("#selectCountry").value; let word2 = $w("#selectprovince").value; let word3 = $w("#selectTown").value; local.setItem("searchWord", word); wixLocation.to(`/services`); }
I have paid somebody a wix expert to help and unfortunately didn't get the job done than.But with your help managed to make it work
Thank you Massa for your help.It is much appreciated.
Good morning!
I took a lot at your editor, It's way simpler than you are doing.
Here's all the code needed in the repeater page:
import { local } from 'wix-storage'; import wixData from 'wix-data'; $w.onReady(function () { $w('#dataset1').setFilter(wixData.filter() .eq("fieldOfStudy", local.getItem("fieldOfStudy")) .eq("location", local.getItem("location")) ) });
However note that this forum is specialized in guiding you through solving your wix code problems and not coding your site. If you need help with building your website feel free to visit wix arena, There's wix experts waiting to get your website ready for you!
Good Luck
Massa
The second option please
User picks-click search-redirects to services page-results shown in the repeater
Hello
So first to get things clear the functionality you want is :
User picks drop down values --> click search --> the repeater shows items based on the drop down value
or
User picks drop down values --> click search --> user gets directed to a page with a repeater showing the result
Hi Massa . I think i managed to make the search work looks like it is searching but now i have difficulties to code the repeater page properly to show the results.would appreciate it if you can have a look please.
I duplicated the home page and tried a different approach in home page copy set it up and now it is redirecting to the services page and in debugger values show up this makes me think that the search works.
Now In the repeater is being populated some value from the database but not what I selectee in the dropdown.
Please help me out.
I am willing to pay for this to make it work
I have set up the button as suggested,and now when I click it redirects to another page-thats a step
Can you help a little bit how to set up the search function on the repeater page please
I guess I need to add the function and set up a function for the search itself,that will display the code to the repeater
Can you help me please.Thank you
export function searchbutton_click() { search(); } function search() { wixData.query
//code that gets the data from the dropdown selection//
.find()
.then(res => {
$w('#repeater1').data = res.items;
});
}
Hello
so first thing you need to add the on click event :
it should be like this: (make sure of the spelling)
This way the function links to service page.
Now in service page you need to get the value from the storage to get it's corresponding data to show on the repeater.
Massa
Thank you @Massa salah for the reply it is much appreciated.
I have fixed the mistake at the export function.
This is the code to the editor.
I have the feeling that my search button click code is wrong,any advice would be appreciated.
Currently the dropdown works perfectly,filters through the values from the database.
The repeater by his own works as well.
Only what I am missing to connect the search button- to connect it to take in consideration the values selected from the dropdown menu start the search and show the correct search results in the repeater.
Thank you
https://editor.wix.com/html/editor/web/renderer/edit/f20f9802-37c7-484c-893a-41bb843bdbcc?metaSiteId=9b415b06-5ad5-47a9-bc28-e99ad73a2129&editorSessionId=1971dc36-88db-5584-98f3-2f443319c284
Hello
Make sure the on click event is added on the properties panel.
can you please provide your editor/website URL
And also here I assume you mean uniqueDropDown4() not uniqueDropDown3() :
export function selectprovince_change(event, $w) { uniqueDropDown3();
Thanks
Massa