WORDPRESS - Oxygen - toolset

Set Dropdown Field Default Value With Javascript

Author: Aleš Sýkora, 30. 8. 2019

If you want to change the -not set- text when using the dropdown field in Toolset form, you must use custom JavaScript. Here is a tutorial how to do it.

Before

Dropdown field default value -- not set -- in Toolset Form
Dropdown field default value -- not set -- in Toolset Forms

After

Dropdown field default value set with jQuery in Toolset Forms
Dropdown field default value set with jQuery in Toolset Forms

Custom Javascript rule to set default dropdown value

Your dropdown field should look like this:

[cred_field field='field-name' force_type='field' class='form-control' output='bootstrap' value='']

Open the form editor and click to the JS editor. Add the jQuery code from below and do not forget to change the field-name and Your-text values ;-).

jQuery(document).ready(function($){
   
 $("select[name='field-name'] option[value='']").text("Your-text");
 
});
Custom Javascript metabox in Toolset Form
Custom Javascript metabox in Toolset Form