How to set a dropdown option

[ad_1]

To set an id of a dropdown you need t o use the SetSelection method which expect and array of the ids of the options to select. So you first need to find the id of the option that you want to select, the dropdown also has a field called OptionItemsToUse that has all the options of the dropdown. So you need to use this array to find the id of the option that you want to use, something like this:

var option id=LoadedForms[0].GetFieldById(3).OptionItemsToUse.find(x=>x.Label=="Option 1").Id

then after having the id of the option you just need to use the set selection as explained. Here is the full code for selecting the option with label “Option 1”

var field=LoadedForms[0].GetFieldById(3);
var fieldId=field.OptionItemsToUse.find(x=>x.Label=="Option 1").Id;
field.SetSelection([fieldId])

Regards!

 

This site will teach you how to build a WordPress website for beginners. We will cover everything from installing WordPress to adding pages, posts, and images to your site. You will learn how to customize your site with themes and plugins, as well as how to market your site online.

Buy WordPress Transfer