Display a different field in repeater from dataset based on dropdown


Is is possible to change the field from a dataset that is displayed in a repeater if a dropdown menu is changed?

Suppose I have a dataset with three fields:
-Distance from London
-Distance from Manchester

I have a repeater in which I want two fields to be displayed from this dataset: 1) Location and 2) Distance from…

If there is a dropdown that is set to ‘Manchester’, then I want ‘Distance from Manchester’ to be displayed. If the dropdown is set to ‘London’, then I want ‘Distance from London’ to be displayed

Is there a way of doing this?


Something like this where you use forEachItem . Just change the element and field names to fit. You wouldn’t need to connect #txtDistance to a dataset field in this example.

export function dropdown_change(event) {
    $w("#repeater1").forEachItem( ($item, itemData, index) => {
       if (event.target.value === "Manchester"){
            $item("#txtDistance").text = itemData.distManchester.toString();
       } else {
            $item("#txtDistance").text = itemData.distLondon.toString();

hey - thank you so much for the quick reply. in the code, where you have ‘itemData’, does that need to be the name of the dataset that is being called?

@alastairholmes It is worthwhile to spend some time with the repeater documentation to get an idea of how Wix/Velo does things with repeaters.

To answer your question, itemData in the forEachItem or onItemReady functions is a variable that stores the data for that repeater item (row), whether you use a dataset to populate the repeater or wixData.query and assign the result of the query to the data property of the repeater.

perfect. thank you :slight_smile: