Filter dropdown selected index value on page load

Hi there, need a little help filtering using SelectedIndex. I have a functioning dropdown using distinctList.

On function loadoptions, I have dropdownSelectedIndex incorporated. :+1:t4:

onReady, I have loadoptions and see the selectedindex populate correctly on the dropdown :+1:t4:, but no data in the table :-1:t4:.

How do I have my table reflect the Selected index value on page load? (On click function filter works on the dropdown, just need help getting that initial data displayed)

I’ve tried filtering the dataset field by $w(β€œ#dropdown”).value onReady, but only confirmed it’s not pulling the value with console log.

Hey @r_enriquez09 ,
Please post your code or an Editor link for your site so we can take a look. Note that only authorized Wix personnel can access your Editor.
Thanks,
Tova

How would I find the Editor link, that may be much easier

@talyaro Does this link work? here

No, it does not work.

@russian-dima Ok, it’s a long code so I’ll only post the code in question

Did you find a solution?

Please post your code in a code block instead of a screenshot as it is much easier to work with.
https://www.wix.com/corvid/forum/community-discussion/corvid-community-guidelines
Format your post . Use code blocks, bullets, etc. to make your post easier to understand.

You can do this by simply selecting all of your code in the post and clicking on the code block icon, as shown here.

Also, with regards to the Wix Editor URL, that is simply the URL that is shown when you are using the Wix Editor itself, which is what you correctly posted in your link.

As @talyaro states, the Wix Editor link is only accessible for Wix themselves as only they have the correct authorisation and permissions to view it.

Finally, as for your code used, you are setting the selected index for dropdown 3 to be number 1, which as the dropdown lists starts at 0, the selected index here will be the second item down in your dropdown list itself.

https://www.wix.com/corvid/reference/$w.Dropdown.html#selectedIndex

Select the first option by index
$w("#myDropdown").selectedIndex = 0;

You can see an example of selectedIndex working here.

W3Schools Tryit Editor

@givemeawhisky My apologies, I’ll post code correctly next time. This is how I want the dropdown, with the second item from the list. This is displaying perfectly but how to I filter by this selectedIndex onReady?

@givemeawhisky My apologies, I will post code correctly next time. This is correct though, I have the selected index at 2nd item on the list and it displays perfectly. How can I filter by the value of this selected index item onReady?

I last tried $w("#dropdown3).options[1].text referring to Tryit Editor and it did not work.

$w.onReady(function () {
    loadPayDates();
    wixUsers.currentUser.getEmail()
        .then((email) => {
 let userEmail = email; //"user@email.com"
    $w('#dataset3').setFilter(wixData.filter()
        .eq("loginEmail", email).eq("payDate1", $w("#dropdown3").options[1].text))
    })
})

function loadPayDates () {
    wixUsers.currentUser.getEmail()
        .then((email) => {
 let userEmail = email; //"user@email.com"
    wixData.query("2020Commissions").eq("loginEmail", email).limit(1000).descending("payDate1").distinct("payDate1").then((results) => {
 let distinctList = results.items.map(element => {return {label: element, value: element};})
        distinctList.unshift({"value": "/", "label": "All Pay Dates"})
        $w("#dropdown3").options = distinctList
 let dropdownSelIndex = $w("#dropdown3").selectedIndex;
        $w("#dropdown3").selectedIndex = 1;
 })

Not quite yet. Took a few days break, so hopefully I find out how to fix this soon!