/
How to clear a Drop-Down from a code snippet?

How to clear a Drop-Down from a code snippet?

Using the Wayfast “clearValue()” function on a Drop-Down List can prove useful if you are attempting to clear a few filter values and want to end up with an empty string instead of the first row.  Within the Data Binding tab of your drop-down field definition: set the “Neutral Element” to “Empty String” and within your “Default Value” field enter in a couple single quotes to define an empty string.   That way when you call the “clearValue” function it will reset to this value instead of preselecting the first row.  Here is an example for a drop-down list control called “JobTitle”:

Drop Down List Data Binding tab:

Code Snippet, attached to the “Reset” button click event:

function resetFilter() {     Wayfast.Controls.get(“JobTitle”).clearValue(); }; resetFilter();

 

 

Related content

Wayfast Javascript Library
Wayfast Javascript Library
More like this
Code Snippets validations
Code Snippets validations
More like this
Dropdown List
Dropdown List
More like this
Button
Button
More like this
Standard Control Settings
Standard Control Settings
More like this