I am creating a site for student accommodation in my city now i want to create a filter search so that user can filter it by location, price range and gender how to write a code for it
I have added a search box for the location search and two drop down menu one for price and one for gender now how to write a code to create a filter search
Seems like Wix provides "just enough" information on code to get you interested...but leaves key elements out and forcing you to seek extended coding work. Search boxes and buttons are VERY fundamental need to use a site, however all these tutorials really leave out any way to implement.
Okay, Will try it.
Thank you Yisrael!
Geo
@Geo,
Just set title to the owner ID. Something like this:
let title = < the owner ID from where you have it >
var or let shouldn't make much difference. let is the "new way".
Hi Yisrael,
how can I identify it?
should I create a let or var?
I want to display items with the same owner id into a repeater.
Thank you,
Geo
@Geo,
You need to set title to the owner ID which as I recall you already have somewhere in your code.
Hi Yisrael,
Good day!
I have one question, again! :D
How can I filter my database collection by owner ID?
I have a code, but it's no working, could you please see what you can help with this?
$w.onReady(() => { wixData.query("regdog") .eq("_owner", tittle) .find() .then((results) => { $w('#repeater1').data = results.items; }) .catch((err) => { console.log(err); }); });
And that tittle word, where can I link it?
Hi Rishabh,
The code I provided is just a skeletal example and is not in any way complete.
You will need to familiarize yourself with basic coding concepts to accomplish what you want. There are a wealth of Javascript coding sites which will help you learn Javascript from basic to advanced - Javascript.info is a good one. The Wix Code Resources provides tutorials, examples, and articles on getting the most out of Wix Code. We are happy to get you pointed in the right direction, but you’ll need to take it from there. As questions or difficulties arise, we are here to help.
You may also want to check out the WixArena - it's a hub where you can look for Wix Code (and other) experts for hire.
Good luck,
Yisrael
I don't know how to write code should I copy this whole code which you have provided
Hey Rishabh,
You would use code somewhere along the lines of the following example:
// the filter values values let loc = < from your location search box >; let gender = < from your gender drop down >; let max = < from your price dropdown >; let min = < from your price dropdown >; // here is the database query on the "accomodations" collection wixData.query("accomodations") .eq("location", loc) .eq("gender", gender) .lt("price", max) .gt("price", min) .find() .then( (results) => { // set the repeater data here } ) .catch( (err) => { let errorMsg = err; } ); // put this in the page's onReady() function $w("#repeater1").onItemReady( ($w, itemData, index) => { // set the repeater elements based on the itemData });
See the $w.Repeater API reference for more information.
I hope this helps.
Yisrael