Reset the dropdown

Hi!

"To reset the dropdown to have no option selected, set the selectedIndex property to undefined ', and " Default Value -1. "
It’s written here

To reset #dropdown3 I used the code.

$w("#dropdown3").selectedIndex= -1

However, there is an error with this code
“Wix code SDK error: The value of selectedIndex parameter that is passed to the selectedIndex method cannot be set to the value “-1”. It must be between 0…”

Who knows how to reset the dropdown?

Hi!

The syntax seems to be correct.
Please share a link to your site so we can look into it.

Doron.

Hi Doron !
The question is still relevant, but is not “hot.” I did it differently.

After loading the page, the statuses of all “dropdowns” are “undefined”.
For example, it is necessary to request several parameters, each of which has several states, then, as a rule, you need to click on the button, confirming the completion of the input operation. The user can skip something. To check the completeness of the input ( Number($w(“#text10”).text) >0), I wrote code for each dropdown


 if ($w("#dropdown1").selectedIndex === undefined) {
        $w("#text10").text = "-1";
        $w("#dropdown1").style.borderColor = "red"
    }

The events for each dropdown were supplemented with a row


export function dropdown1_click(event, $w) {
...
   $w("#dropdown1").style.borderColor = "black";
}

An example is when the user forgot to enter something. https://georrus.wixsite.com/fireandalp/vybor

Maybe this is trivial, since all the wix forms have a check for completeness, but I did not use the wix form here

Thank you, Doron.

Hi Александр Ч,
If you are looking for a simple way to reset forms and reset validity, here is a good example.
https://www.vorbly.com/Vorbly-Code/WIX-CODE-RESET-FORM-WITH-BUTTON
Cheers,
Ben

This is an old post but I tried this and when I reset the fields it for the dropdown only gave me the option to choose what I had chosen the time before