Written by: Aleš Sýkora

The Author of Toolset.wiki. Big fan of Toolset plugins and WordPress.

I am big fan of WordPress and Toolset plugins. I have done many projects based on WordPress. I also have experience with online marketing, PPC advertising and SEO. I live in Czech Budweis – the town of Budweiser Budvar breverage in the south of the Czech Republic – the heart of Europe.

I love skateboarding, snowboarding, frisbee, fitness, healthy lifestyle, tattoos, mountain biking and other sports. I enjoy having time with friends with good beer and good music.

Set Dropdown Field Default Value With Javascript

Last Update: 10. 11. 2019 , Category:

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

Support Us via our Affiliate link!

Toolset logo WordPress

What to do next?

Need a Toolset License?

Buy via affiliate link!

Looking for a tutorial?


Help other users – Add your snippet!


Join the discussion!