Cognito Forms – How to Set Default Value in Second Dropdown Based on First

cognito-forms

For example if I have:

"Store" drop down section and under the section the options will be:

Washington
Virginia
Maryland

and second drop down section will be default value depends on the "Store" drop down section:

"Address"

970 Goodluck rd Washington 20007 \\If I choose Washington this option will be default value
467 wingate rd Virginia 21007    \\If I choose Virginia this option will be default value
764 drake ct Maryland 21056      \\If I choose Maryland this option will be default value

How can I do that?

Best Answer

You can specify default values for most types of fields in Cognito Forms. When these default values are calculations that reference other fields, the value of the field will be automatically updated when the field referenced in the calculation changes.

In your case, the following calculation should work. Just verify field names and make sure the text values in the calculation match your choice values exactly (case sensitive).

Set Default Value for Address to:

=if Store = "Washington" then "970 Goodluck Rd Washington 20007" else
 if Store = "Virginia" then "467 Wingate Rd Virginia 21007" else
 if Store = "Maryland" then "764 Drake Ct Maryland 21056" else
 ""