How to code dropdown selections?

Hi I’m trying to tie different dropdowns with different sorting patterns I think I have something that could work but I’m not sure. if anyone wants to take a look at this and tell me what I’m doing wrong I would be really appreciative.

export function sortInput_change(event, $w) {
//Add your code for this event here:
if ($w(‘#sortInput’).value === “nameAtoZ”);
$w(“#dataset1”).setSort(wixData.sort()
.ascending(“title”))

if ($w(‘#sortInput’).value === “nameZtoA”); {
$w(“#dataset1”).setSort(wixData.sort()
.descending(“title”))
}
}

Try:

import wixData from 'wix-data';
$w.onReady(() => {
    $w('#dataset1').onReady(() => {
        $w('#sortInput').onChange(event => {
            let sort = wixData.sort();
             if ($w('#sortInput').value === 'nameAtoZ') {
                sort = sort.ascending('title');
            } else if ($w('#sortInput').value === 'nameZtoA') {
                sort = sort.descending('title');
            }
            $w('#dataset1').setSort(sort);
        })
    })
});

[updated]

Oh yes this is exactly what I needed thanks so much!

You’re welcome :slight_smile: