How can i reset the dropdown selections?
can i clear the dropdowns items?
Important forum update
This forum is migrating to one unified Wix community forum starting July 26th, and will be read-only during the process.
Wishlist Page is the official platform for requesting new features. You can vote, comment, and track the status of the requested features.
I was finally able to make this work. I have 5 dropdowns that all pull their information from one dataset. I added a button and used the below code to return all values to the placeholder text, which on my page is "Select". It took me a long time to figure this out as I am a first time coder. Several of the examples I tried just would not work. Be sure to set the button properties to "onClick()"
export function button3_click(event, $w) { // This function was added from the Properties & Events panel. // Add your code for this event here: $w("#dropdown1").selectedIndex = null; $w("#dropdown2").selectedIndex = null $w("#dropdown3").selectedIndex = null; $w("#dropdown4").selectedIndex = null; $w("#dropdown5").selectedIndex = null; }
Hi guys!
Note that the two methods are different with different purposes.
The ".placeholder" method changes the default writing in the input field, you can even say it changes the title of the field.
The ".value" method changes the value of the user's input. Lets say that I have an input field for a phone number. The 'placeholder' is - Phone Number;
While the value will be my input would be: +123 45 - 6789 - 012.
Other than that, #Nithin, your code seems fine.
Make sure that you use the correct selector name (aka Component ID; aka $w('#yourComponent') ) and that the event of 'sortbutton_click' exists in the button's properties.
Hope it helps!
Doron.
Hi Nithin,
You can reset the value of the dropdown elements to the placeholder text.
export function sortbutton_click(event) { $w("#stateselectbutton").value = "Select State:"; $w("#adtypeselectbutton").value = "Select Type:"; $w("#typeselectbutton").value = "Select Category:"; }
You can refer to this website on how to reset dropdown elements.
https://www.vorbly.com/Vorbly-Code/WIX-CODE-RESET-FORM-WITH-BUTTON
Good luck!
Cheers,
Ben
Hi Giedrius,
I want to reset the drop down placeholder to default value when a button is clicked. I used code as shown here.
export function sortbutton_click(event) { $w("#stateselectbutton").placeholder = "Select State:"; $w("#adtypeselectbutton").placeholder = "Select Type:"; $w("#typeselectbutton").placeholder = "Select Category:"; }
But unfortunately its not resting the place holder. Am I doing anything wrong?
Hi,
you can set dropdown selections by setting options property on a dropdown. You can also clear the options by setting it an an empty array.
You can find full API here:
https://www.wix.com/code/reference/$w.Dropdown.html#options