Create Cascading Form to search State > City

Hi Velo community! I’m attempting to be able to search for profiles based upon location (City/State). On the profile creation page, its easy to add an address box and the person creating the profile can add their Location by City/State, and save this information. This then gets uploaded into a dataset as text. When creating a search page by location this is where I can’t get the code correct to search by location.

Is it possible when creating a profile that a member can select a state through a dropdown menu of the 50 states. Then, after the state is selected, the cities from that state are then populated on a 2nd dropdown menu and that City is selected and placed into the dataset as a Tag?

That way, on the Profile search page, I can connect all of the dropdown menu’s to the dataset and filter the results through a repeater that has all of the individual profiles?

I have not found any tutorials on creating a cascading menu where if you select the first option (State) then it populates all of the cities from that state in a 2nd Dropdown.

Any ideas??

Your wished functionality is doable by CODE.

There are several ways of how to solve it.

  1. DATASET-WAY
  2. WIX-DATA-WAY
  3. MIXED-WAY

What would be your steps?

  1. Choose item from FIRST-DROPDOWN → GETTING RESULTS !!!
  2. RESULTS adding to SECOND-DROPDOWN
  3. Choosing item from SECOND-DROPDOWN → GETTING AGAIN SOME RESULTS
  4. Adding the SECODN-RESULTS whereever you want.

https://www.wix.com/velo/reference/wix-data/query

$w.onReady(()=>{
	$w('#myDropdown1_IDhere').onChange(()=>{
		console.log("starting first filtering-process here");
		start_Filter1();
	});
});

function start_Filter1() {
	// use for example Wix-Data-Api here to get the filtered results.
	// or do it by the usage of a connected dataset to your database.
	//either write the results immediately to the dropdown_1 or return themback to the main-function and add them to the second dropdown.
	
}

Repeat these actions for DROPDOWN-2.

Maybe, after reading this post here, you will get some more ideas, who knows…

Thank you Ninja! I think the MIXED-DATA Way would be the route.

Yes, This is how I would imagine the search to occur:

  1. Choose item from FIRST-DROPDOWN → GETTING RESULTS !!!
  2. RESULTS adding to SECOND-DROPDOWN
  3. Choosing item from SECOND-DROPDOWN → GETTING AGAIN SOME RESULTS
  4. Adding the SECOND-RESULTS wherever you want.

It is easy to put the 50 states into the dropdown and have it connected to a dataset. The problem would come when you have all of the individual cities of the US in a dataset (That’s a lot of cities). I have no problem entering them. The problem occurs at the vast number of cities in a drop down at once.

The best solution would be for example:

I select form one of the 50 states. Let’s say it is Florida. When I select that, all of the profiles in the Repeater associated with the state of Florida pop-up.
Next, when Florida is selected, the 2nd Dropdown then populates all of the cities in Florida. The user can then select from the cities in Florida. Once the City is selected, their search narrows down and more specific profiles are now populated in the Repeater and the user can select the profile they want to view from there.

This is not an easy process, and really appreciate your help!

What you are searching for is exactly described in the linked post i gave you in my last answer.

The CODE shown in the example works like the following…

  1. Searching automatically inside of predefined DATABASE for “UNIQUE-ITEMS” / “UNIQUE-DATA”…

  2. …and pulling the results into a preselected/predefined dropdown.

  3. You even don’t have to create a specific list with all your wanted CITIES, because the code already take all the infos directly from your database.

Read very carefully the POST and try to understand each of the steps.

The POST will show you all the little intermediate-steps and all the problems you normaly would facing when creating such an automated function, for first time.

The POST-OPENER was also a → beginner, but he was able to manage his problem and if you read and study it, you will also have success.

About the MIXED-MODE → it’s really not recommended to take this way, if you are a beginner. Mixing Wix-Data and Datasets —> in about 90% will cause problems (at least for beginners).

Try to work the LOGIC-WAY → STEP-BY-STEP BRAINSTORMING and CODING…

…like you do here…

I select form one of the 50 states. Let’s say it is Florida. When I select that, all of the profiles in the Repeater associated with the state of Florida pop-up.

Next, when Florida is selected, the 2nd Dropdown then populates all of the cities in Florida. The user can then select from the cities in Florida. Once the City is selected, their search narrows down and more specific profiles are now populated in the Repeater and the user can select the profile they want to view from there.

Write down all needed steps in the right sequence,

Maybe with a starting CLICK onto a button…

  1. User clicks a button or choose from dropdown.
  2. A functions starts …
  3. Returning first results…
  4. and so on.

After you have your logical structured notices, you start to code them

  1. For the very first what you code is always…
$w.onReady(()=>{console.log("Page is READY...");
	//continue coding here....
});
  1. Then you add more and more functions and actions to your code, like for example the selected choice of the the dropdown…
$w.onReady(()=>{console.log("Page is READY...");
	$w('#myDropdown1_IDhere').onChange(()=>{
	
	});
});
  1. What should happen in the next step ? —> Yes we want to start the first filtering function, so let us create this function…
$w.onReady(()=>{console.log("Page is READY...");
	$w('#myDropdown1_IDhere').onChange(()=>{
		my_Searchfunction();
	});
});
  1. Now we need to define this function “my_Searchfunction()”, and tell the function what to do if the function has been called by code…

Creating the function - - → “my_SearchFunction()”

function my_SearchFunction() {
	
}

What has to be done inside of the function? You wanted to start a FILTER-FUNCTION, right? So let’s do it…(by using the query of Wix-Data-Api)…

function my_SearchFunction() {
  wixData.query("myCollection")
  .find()
  .then((results) => {
    if(results.items.length > 0) {
      console.log("RESULTS: ", results.items)
      console.log(results.items[0]); 
    } else {
      console.log("No matching items found");
    }
  })
  .catch((err) => {console.log("ERROR: ", err);});
}

When working with Wix-APIs, you first have to → IMPORT them to your PROJECT.

So let’s not forget first to import them…
This line goes to the very top of your code.

import wixData from 'wix-data';

Your code till this checkpoint…

import wixData from 'wix-data';

$w.onReady(()=>{console.log("Page is READY...");
	$w('#myDropdown1_IDhere').onChange(()=>{
		my_Searchfunction();
	});
});

function my_SearchFunction() {
  wixData.query("myDATABASE_ID_here")
  .find()
  .eq("add_DB-FIELD_here", "add_VALUE_here")
  .then((results) => {
    if(results.items.length > 0) {
      console.log("RESULTS: ", results.items)
      console.log(results.items[0]); 
    } else {
      console.log("No matching items found");
    }
  })
  .catch((err) => {console.log("ERROR: ", err);});
}

You got your FISRT-RESULTS!!!

DB-FIELD → The field where you want to find your items (STRING.
VALUE - → The value you are searching for (STRING).

What next? - - > CONTINUE…

Thank you Ninja! I read through that entire thread last night and will go through this process step by step. My experience is probably similar to that persons with coding and truly appreciate your time and dedication to making us all better! Time to get moving on this segment of the website

One more question before I begin this coding process. Currently in the profile creation, I have the person use an address input to identify their City, State, and it pops up as Field Type: ADDRESS in the dataset. Should I change this to the two dropdowns with City and State as separate fields in the Dataset and have it set up as a Field Type: TAG to make the search correlate easier?

If you would be the user who uses the form.

Which one of two possibilities you would prefere?
Which one is more user-friendly out of your point of view?

It’s your descision, which one you want to use.
If it would be me - → i would prefere the easy to use DropDown.

2-clicks (one to open the dropdownlist and second to select what i need)
instead of typing in some adress.

And yes, i would separate STATES and all the related CITIES into 2 different DB-Fields.

For example:

--------DB-FIELD-STATES ------------------------DB-FIELD-CITIES--------------
---------------STATE-1--------------- ---------------CITY-1, CITY-2, CITY-11---------------
---------------STATE-2--------------- ---------------CITY-6, CITY-5, CITY-9---------------
---------------STATE-3--------------- ---------------CITY-2, CITY-3, CITY-4---------------
---------------STATE-4--------------- ---------------CITY-7, CITY8, CITY10---------------

-----------STRING-FIELD--------- -------------------------TAG-FIELD---------------------

But you can structure your DATABASE also in another way, for example using 2x STRING-FIELDS.

The most important is always the structure of your database, because all data comes from DATABASE.

Agreed! As a User, the two dropdowns will be the best option. I will go through the coding now. The most challenging thing will be separating the cities of the individual 50 states. Its not user friendly to have 50 separate dropdowns for 50 different states, so will go through and figure out how to filter so only the cities from the state selected from the first dropdown to populate on the 2nd dropdown.

Good evening Ninja,

I hope you have had a good end to your week! You mentioned with the coding, that I can pull info form the Database to get the CITIES:

The challenge I have come across here is that on the profile creation page, currently I have the Field Type: ADDRESS, where the person simply types in their city and clicks on their CITY when it pops up in the Address Input Box, like here:

So, as you said, the Dropdowns will be pulling all of the information from the Database. With this being the case, I can either attempt to code in the profile search page with ADDRESS INPUT BOX or use the Dropdowns, but will need to create Dropdowns in the Profile creation page as well.

I like the Dropdown option the best, like you said, because that’s most user friendly. If I’m going to do that, I’ll need to add each individual city into the dropdown menu on the Profile Creation Page, because that information will not be able to be pulled from the Database at this stage in the website. I need to figure out the coding as to separate the CITIES from the individual 50 states.

Thoughts?

Essentially what I am looking to do is almost exactly on the Wix Marketplace Website on the “Location & Language” Dropdown.

You can select the city and/or state and click “Apply” and in the Repeater shows all of the available vendors on the Wix Marketplace

Yes, this is exactly what the provided code in the mentioned post will do.

What you will need to be able to create the function?

  1. 2x Dropdowns —> STATE-Dropdown + CITY-Dropdown.

I’ll need to add each individual city into the dropdown

  1. you don’t have to fill anything manually, aslong all the data is already inside of your databse. Everything works full-automatic, without any manual actions.

  2. COPY and PASTE the provided CODE…

Here a little bit modified CODE for your FIRST-UNIQUE and automatic generated DROPDOWN…

All you have to do is to FILL-OUT all the ELEMENT-IDs, of your own used ELEMENTS… (marked in → ORANGE )

If you do not want to switch the OUTPUT-DATA, then OUTPUT_FIELD equals DBFIELDS[0]

import wixData from 'wix-data';

var DBFIELDS=[], DD_ID=[], OUTPUT_FIELD=[]; 
//-------- USER-INTERFACE -------------------------
var DBLIMIT = 1000;
var DATABASE = "YOUR_DB_ID_HERE" 
//---[ Dropdown-Settings]---------------------
  DD_ID[0] = "#your_DROPDOWN-ID_here" 
//---[ DB-INPUT-Field-Settings]--------------
  DBFIELDS[0] = "your_DB-Field-ID_here"  
//---[ DB-OUTPUT-Field-Settings]--------------
  OUTPUT_FIELD[0] = "OUTPUT_FIELD_ID_HERE" //<--- DEFINE-OUTPUT-FIELD-here 
//-------- USER-INTERFACE ---------------------------
 
$w.onReady(async()=>{
   let ITEMS = await get_DBdata(DATABASE); 
   create_UniqueDropdown(ITEMS,DBFIELDS[0],DD_ID[0]); 

  $w(DD_ID[0]).onChange(()=>{
     let INDEX = $w(DD_ID[0]).selectedIndex
     console.log(ITEMS[INDEX][OUTPUT_FIELD[0]]); 
   });
}); 

function create_UniqueDropdown(items, dbfield, dropdown) {
  const uniqueTitles = getUniqueTitles(items);
  $w(dropdown).options = buildOptions(uniqueTitles); 
 
  function getUniqueTitles(items) {
    const titlesOnly = items.map(item => item[dbfield]); 
    return [...new Set(titlesOnly)];
  }

  function buildOptions(uniqueList) {
    return uniqueList.map(curr => {
      return {label:curr, value:curr};
    });
  }
}

function get_DBdata(DATABASE) {
  wixData.query(DATABASE)
  .limit(DBLIMIT).find()
  .then(results=> {
     let ITEMS = results.items 
     return (ITEMS)
  }); 
}

Example-Setup…

-Your Dropdown-ID - - -> "ddn1"
-Your DATABASE-ID - - > "myDatabase"
-Your DBFIELDS[0] =  ID of the DATABASE-FIELD you want to get data from
-You do not want to switch OUTPUT-VALUE --> 
OUTPUT_FIELD[0] = DBFIELDS[0]

You have only to edit the USER-INTERFACE-SECTION, nothing else.
Do not touch the CODE itself !

After you have setted-up the first working Dropdown, create a second function and by some little modifications, you can connect your second full automatically running dropdown to the first one.

RESULT:

  1. When page loads - - > Dropdown-1 gets loaded automaticaly with UNIQUE-VALUES out of your selected DATABASE and the corresponding DB-FIELD.
  2. When first dropdown has been filled, you generate a second (very similar) function to the first one and connect the second dropdown to the selected-value of the first one.

That means —> when user selects from first UNIQUE-Dropdown, a function starts to filter for the selected VALUE of the first DROPDOWN and puts again unique found results into the second Dropdown.

Et VOILA! That’s it! :wink:

What you want to do with your ADDRESS-INPUT-FIELD → i don’t know, you can keep it or hide it.

BY THE WAY:
I did not test the code, maybe you could get the one or the other error, which you will have to manage and fix by your own.

And like always - → do not forget to like it, if you really liked it! :wink:

Good evening Ninja,

Thank you again for your feedback! I have entered the code and have no reported errors, but am getting no response when I run the code in preview. There is no change that occurs with the Repeater

import wixData from ‘wix-data’;

var DBFIELDS=, DD_ID=, OUTPUT_FIELD=;
//-------- USER-INTERFACE -------------------------
var DBLIMIT = 1000;
var DATABASE = “Items1”
//—[ Dropdown-Settings]---------------------
DD_ID[0] = “#stateDropdown1
//—[ DB-INPUT-Field-Settings]--------------
DD_ID[2] = “#cityDropdown2
// <–setting Dropdown-ID here…(2nd. dropdown)
DBFIELDS[0] = “state”
//—[ DB-OUTPUT-Field-Settings]--------------
DBFIELDS[2] = “city”
// <–setting DATABASE-Field-ID (2nd. DB-Field)
OUTPUT_FIELD[0] = “DBFIELDS[0]” //<— DEFINE-OUTPUT-FIELD-here
//-------- USER-INTERFACE ---------------------------

$w.onReady(async()=>{
let ITEMS = await get_DBdata(DATABASE);
create_UniqueDropdown(ITEMS,DBFIELDS[0],DD_ID[0]);

$w(DD_ID[0]).onChange(()=>{
let INDEX = $w(DD_ID[0]).selectedIndex
console.log(ITEMS[INDEX][OUTPUT_FIELD[0]]);
});
});

//—First ACTIVATED-Dropdown…
function create_UniqueDropdown(items, dbfield, dropdown) {
const uniqueTitles = getUniqueTitles(items);
$w(dropdown).options = buildOptions(uniqueTitles);

function getUniqueTitles(items) {
const titlesOnly = items.map(item => item[dbfield]);
return […new Set(titlesOnly)];
}

function buildOptions(uniqueList) {
return uniqueList.map(curr => {
return {label:curr, value:curr};
});
}
}

function get_DBdata(DATABASE) {
wixData.query(DATABASE)
.limit(DBLIMIT).find()
.then(results=> {
let ITEMS = results.items
return (ITEMS)
});
}

//—Second ACTIVATED-Dropdown…

$w.onReady(async()=>{
let ITEMS = await get_DBdata(DATABASE);
create_UniqueDropdown2(ITEMS,DBFIELDS[2],DD_ID[2]);

$w(DD_ID[2]).onChange(()=>{
let INDEX = $w(DD_ID[2]).selectedIndex
console.log(ITEMS[INDEX][OUTPUT_FIELD[0]]);
});
});

function create_UniqueDropdown2(items, dbfield, dropdown) {
const uniqueTitles = getUniqueTitles(items);
$w(dropdown).options = buildOptions(uniqueTitles);

function getUniqueTitles(items) {
const titlesOnly = items.map(item => item[dbfield]);
return […new Set(titlesOnly)];
}

function buildOptions(uniqueList) {
return uniqueList.map(curr => {
return {label:curr, value:curr};
});
}
}

function get_DBdata2(DATABASE) {
wixData.query(DATABASE)
.limit(DBLIMIT).find()
.then(results=> {
let ITEMS = results.items
return (ITEMS)
});
}

Here’s how the screen shot of the code looks:

How is this able to connect to Repeater?

Were you already able to find your answer onto this issue ???

Check the —> “get_DBdata2()” -function and update it like this one…

function get_DBdata(DATABASE) {
  return wixData.query(DATABASE)
  .limit(DBLIMIT).find()
  .then(results=> {console.log(results);
     let ITEMS = results.items 
     return (ITEMS)
  }); 
}

There was a missing → RETURN

Also you do not need 2x —> $w.onReady() !!!
Also you do not need a second —> get_DBdata(DATABASE)-function.
You also do not need to generate a second …

create_UniqueDropdown2(.....)-function;

This line here …

create_UniqueDropdown(ITEMS,DBFIELDS[0],DD_ID[0]);

…does the magic to fill a second or a third added DROPDOWN with data.

All you have to do is…

create_UniqueDropdown(ITEMS0,DBFIELDS[0],DD_ID[0]);
create_UniqueDropdown(ITEMS1,DBFIELDS[1],DD_ID[1]);
create_UniqueDropdown(ITEMS2,DBFIELDS[2],DD_ID[2]);

…and of course, you have first to define the following first…

//—[ Dropdown-Settings]---------------------
DD_ID[0] = “dropdown1”; //“dd1”
DD_ID[1] = “dropdown2”; //“dd2”
DD_ID[2] = “dropdown3”; //“dd3”
//—[ DB-INPUT-Field-Settings]--------------
DBFIELDS[0] = “xxxxx” //<— DEFINE-INPUT-FIELD-here
DBFIELDS[1] = “yyyyy” //<— DEFINE-INPUT-FIELD-here
DBFIELDS[2] = “zzzzz” //<— DEFINE-INPUT-FIELD-here
//—[ DB-OUTPUT-Field-Settings]--------------
OUTPUT_FIELD[0] = “xxxxx” //<— DEFINE-OUTPUT-FIELD-here
OUTPUT_FIELD[1] = “yyyyy” //<— DEFINE-OUTPUT-FIELD-here
OUTPUT_FIELD[2] = “zzzzz” //<— DEFINE-OUTPUT-FIELD-here

I just did a test on my own test-page… with the following code… (in my case i used just one dropdown as example).

WORKING CODE:

import wixData from 'wix-data';

var DBFIELDS=[], DD_ID=[], OUTPUT_FIELD=[]; 
//-------- USER-INTERFACE -------------------------
var DBLIMIT = 1000;
var DATABASE = "Books" 
//---[ Dropdown-Settings]---------------------
  DD_ID[0] = "ddn1";
//---[ DB-INPUT-Field-Settings]--------------
  DBFIELDS[0] = "title"  
//---[ DB-OUTPUT-Field-Settings]--------------
  OUTPUT_FIELD[0] = "title" //<--- DEFINE-OUTPUT-FIELD-here 
//-------- USER-INTERFACE ---------------------------
 
$w.onReady(async()=>{
   let ITEMS = await get_DBdata(DATABASE); 
   console.log("ITEMS: ", ITEMS);
   create_UniqueDropdown(ITEMS,DBFIELDS[0],DD_ID[0]); 

  $w('#'+DD_ID[0]).onChange(()=>{
      let INDEX = $w('#'+DD_ID[0]).selectedIndex
      console.log(ITEMS[INDEX][OUTPUT_FIELD[0]]); 
  });
}); 

function create_UniqueDropdown(items, dbfield, dropdown) {
  const uniqueTitles = getUniqueTitles(items);

  let options = buildOptions(uniqueTitles); 
  console.log(options);
  $w('#'+dropdown).options = options;
 
  function getUniqueTitles(items) {
    const titlesOnly = items.map(item => item[dbfield]); 
    return [...new Set(titlesOnly)];
  }

  function buildOptions(uniqueList) {
    return uniqueList.map(curr => {
      return {label:curr, value:curr};
    });
  }
}

function get_DBdata(DATABASE) {
  return wixData.query(DATABASE)
  .limit(DBLIMIT).find()
  .then(results=> {console.log(results);
     let ITEMS = results.items 
     return (ITEMS)
  }); 
}

…and my dropdown just worked like a charm…

Good evening Ninja,

I hope you had a Merry Christmas!!! I had not found a resolution to this issue yet. Thank you very much for your feedback. I will work on entering this into code tomorrow, and see how it is functioning on page and will let you know how it is running. Thank you again for all of your continuous help!!

Do you have any recommendations on learning to code books or education video’s? I have started reading a Learning Javascript Book.

Best way to learn is —> LEARNING BY DOING !

Read post here and try to REBUILD them and memorize all coding techniques, which are new to you.

Learning a programming-language is nothing else then learning a normal speaking language, which is new to you.

You have first to know all the basics (vocabularies), like …

  • what is a CODING-SYNTAX ?
  • what is a variable ?
  • are there different types of variables given ?
  • what is a constant ?
  • how to define a variable ?
  • what is an ARRAY ?
  • how to declare and define an ARRAY?
  • what is an OBJECT ?
  • how to declare and define an OBJECT ?
  • what is a FUNCTION ?
  • how to generate a FUNCTION ?
  • what is an API ? what is an REST-API ?
  • how to use the CONSOLE and produse CONSOLE-LOGS ?
  • what for do i need the mentioned CONSOLE-LOGS ?

…and there are many many more questions you should first find an ANSWER for, before you can start really to do some CODING-MAGIC

When i started my CODING-ADVENTURE, i didn’t know all these things, i just heard about them, but never new in detail, what it is, how it works and what it does.

You will need a lot of time and your first FIGHTING-ROUNDS will be hard, but the harder your FIGHTING-ROUNDS against the CODE-MONSTER —> the more you will learn.

A GOOD-CODER —> NEVER-GIVES-UP !!! :stuck_out_tongue_winking_eye:

These was my beginning… →

https://russian-dima.wixsite.com/meinewebsite/blank-5

Just collected some POSTS and always tried to REBUILD them.
My recommendation how to learn JS, CSS, HTML, and all the VELO-APIs, and much more.

When i now look back to my coding-history, i sometimes start to laugh :rofl:

Another way of how to learn code faster is to work on own projects.

For example: You have an idea and you want to generate a cool LOGIN-SYSTEM. You start to do → BRAINSTORMING about…

  1. DESIGN of your LOGIN-SYSTEM ?
  2. INCLUDED FEATURES & FUNCTIONS ?
  3. MAYBE EVEN SOME KIND OF OWN INTEGRATED SPECIAL-STUFF?

Here your → CODING-ADVENTURE beginns.

You can go the ODD-WAY, like everybody and follow a way, which was already gone by many, or you can try to find new ways, new possibilities, new options and gain new coding techniques, made by your own.

An EXAPLE for such an ADVENTURE-PROJECT you will find when you look into my PROFILE and find one of many of my posts about —> LOGIN-SYSTEM.

This is just one example, to show you how to learn CODING on your own.

Or you can read all my 6500+ posts and follow my foot-steps :rofl:

I am definitely going to start learning more about this foreign language! It’s very interesting!!! Thank you for this information!

Happy New Year Ninja! I have input the code. I am getting no errors, but not getting a response with the drop downs. No datasets are connected. The repeater has the first profile that’s in my dataset. When I attempt to search, no additional profiles filter through the Repeater. Here is my code:

import wixData from ‘wix-data’;

var DBFIELDS=[], DD_ID=[], OUTPUT_FIELD=[];
//-------- USER-INTERFACE -------------------------
var DBLIMIT = 1000;
var DATABASE = “Items1”
//—[ Dropdown-Settings]---------------------
DD_ID[0] = “#stateDropdown1
DD_ID[2] = “#cityDropdown2
//—[ DB-INPUT-Field-Settings]--------------
DBFIELDS[0] = “state”
DBFIELDS[2] = “city”
//—[ DB-OUTPUT-Field-Settings]--------------
OUTPUT_FIELD[0] = “DBFIELDS[0]”
//-------- USER-INTERFACE ---------------------------

$w.onReady(async()=>{
let ITEMS = await get_DBdata(DATABASE);
console.log("ITEMS: ", ITEMS);
create_UniqueDropdown(ITEMS,DBFIELDS[0],DD_ID[0]);

$w(‘#’+DD_ID[0]).onChange(()=>{
let INDEX = $w(‘#’+DD_ID[0]).selectedIndex
console.log(ITEMS[INDEX][OUTPUT_FIELD[0]]);
});
});

function create_UniqueDropdown(items, dbfield, dropdown) {
const uniqueTitles = getUniqueTitles(items);

let options = buildOptions(uniqueTitles);
console.log(options);
$w(‘#’+dropdown).options = options;

function getUniqueTitles(items) {
const titlesOnly = items.map(item => item[dbfield]);
return […new Set(titlesOnly)];
}

function buildOptions(uniqueList) {
return uniqueList.map(curr => {
return {label:curr, value:curr};
});
}
}

function get_DBdata(DATABASE) {
return wixData.query(DATABASE)
.limit(DBLIMIT).find()
.then(results=> {console.log(results);
let ITEMS = results.items
return (ITEMS)
});
}

Here is a video with the states already entered into the drop-down:

Here is a video when I remove the states from the drop-down. They do not populate on their own from the dataset.

If you want to work your dropdowns inside of REPEATER, you will have to code additional code and to modifiy it.

Dropdowns inside REPEATER do work different then outside of REPEATER.

First test them outside repeater.
Check result, if it works.
Then do next step and try to implement them into repeater, by changing CODE

!!! $w is not $item !!!

You will later know what i mean.

So, I need to be able to code for the profile creation page to be able to pull up the state and then the city in 2 separate dropdowns.

Then on my profile search page, I want to search profiles by State, then city. I’m not really sure what you mean by inside and outside of the repeater. I thought if the dropdowns were on the same page as the repeater, then they would filter the results… I’m confused by the inside/outside repeater meaning???