Execute a button's click via wix code instead of a user clicking the button

So my dynamic page has a filter options that decide what data to show. The user can adjust the filter to show another set of results.

To make the experience better I’d like to have a “default” set of values for the filter and show the results for that default set first (while letting the user know that they can adjust it).

The problem is I can’t seem to be able to “execute” the click of the button.

Here’s what I’m doing in the code:

//set default procedure for the page
let chosenProcedure = 'MRI Scan Without Contrast';

//set the dropdown to be the default and execute button 
$w.onReady(function () {
   $w("#procedureDropdown").value = chosenProcedure;
   button2_click();
});

export async function button2_click(event) {
   //lots of code that shows the right data in the repeater 
}

Any idea why isn’t it working?

Hey, Maayan!

You can simply hard code desired value(s) to be displayed by default. Either retrieve them from the relevant database or use variables to store them.

Here you can find an example https://www.wix.com/corvid/reference/$w.Dropdown.html#value

In order to properly check what exactly you are trying to achieve, please provide us with the site link.