Complicated request. Select dataset element using a dropdown

I’m really new to wix but I have relatively complex idea I’m trying to figure out. What I want to be able to do is have a dropdown menu from which I can select an entry (in this case 1-30) and then use that to get the data from a corresponding row in my data collection table.
Preferably, I’d like to be able to render the information there on the page using text boxes or use the number to set a URL to go to on a dynamic page. I assume I have to do this via code but I’m not having much luck figuring out the functionality.

1 Like

Welcome,

Actually, with wix-code, what you are trying to do is fairly simple.
Use the onChange hook over your dropdown component (Dropdown - Velo API Reference - Wix.com) to retrieve the selected option.
Then, use wix-data find method (https://www.wix.com/code/reference/wix-data.WixDataQuery.html#find) to find the corresponding row.

To change a text box, you can use $w again (https://www.wix.com/code/reference/$w.Text.html).
To redirect to browser to a different URL, use wix-location: wix-location-frontend - Velo API Reference - Wix.com.

Good luck!
Idan.

Alright that helped a fair bit. After playing around with the site and the code a bit, I found the closest I can get to the functionality i want is to put a buttons connected to my data set that link to Next and Previous item. Doing that, I was able to get the text boxes to update their values instantly if I can figure out how to do the same thing with the dropdown OnChange event instead so I can jump to any item rather than scrolling though one at a time, I think I’ll be golden.

Hi,

You can use dynamic pages with a checkbox (just create a new checkbox and connect it to your data set).
However, this will redirect to a new url (a new page for each row).

If you want to stay on the same page and change the text, you can do it manually as I mentioned before:

  • create a new checkbox
  • create an onChange event, and find the corresponding row using wix-data
  • change the text using $w.

Good luck,
Idan.

I have almost the same issue : which code can I use to fill a dropdown list with several items (just one field) from another field selected in a previous dropdown?

I have 2 dropdown. One to choose a category and I want that when I choose a category in the dropdown1, all elements from this category appears in the dropdown2 (just the name of it).

My code for retrieving the item in the first dropdown works and is :

export function dropdown2_change(event, $w) {
//récupération catégorie choisie dans la liste déroulante
let choixCategorie = event.target.value;
console.log(choixCategorie);
}

But how to make my query to find all items from this category and put them in the second dropdown?
Thank you.