Get value of dropdown field
Function: Get value of dropdown field
This action allows you to retrieve the currently selected option from a dropdown menu on your application's form. It captures the unique identifier (code) of the chosen item and stores it in a variable, making it available for further use in your application's logic. This is useful when you need to react to a user's selection, such as displaying different fields, performing calculations, or filtering data based on their choice.
Input
- UI element: This is the specific dropdown field on your form from which you want to get the selected value. You must select a dropdown field UI element for this action to work correctly.
Output
- Answer: This is the name of the variable where the unique identifier (code) of the selected dropdown option will be stored. By default, this variable will be named
DROPDOWN_FIELD_ANSWER, but you can change it to something more descriptive if needed. The value stored will be a piece of text (STRING).
Execution Flow
Real-Life Examples
Here are some examples of how you can use the "Get value of dropdown field" action:
Example 1: Displaying a specific message based on country selection
Imagine you have a form where users select their country from a dropdown. You want to display a welcome message tailored to their country.
- Inputs:
- UI element: Select the dropdown field named "Country Selection".
- Result: If the user selects "USA" from the dropdown, the action will store the code "USA" (or whatever unique code is assigned to USA) into the
DROPDOWN_FIELD_ANSWERvariable. You can then use this variable in a subsequent action to display a message like "Welcome, American user!".
Example 2: Adjusting shipping costs based on state selection
You have an e-commerce checkout form where customers choose their state from a dropdown. You want to calculate different shipping costs based on the selected state.
- Inputs:
- UI element: Select the dropdown field named "Shipping State".
- Answer (variable name):
SelectedStateCode
- Result: If a user selects "California" (with code "CA"), the action will store "CA" into the
SelectedStateCodevariable. You can then use thisSelectedStateCodevariable in a conditional logic block to apply a specific shipping rate for California.
Example 3: Filtering a list of products by category
On a product browsing page, you have a dropdown that allows users to filter products by category (e.g., "Electronics", "Clothing", "Books").
- Inputs:
- UI element: Select the dropdown field named "Product Category Filter".
- Answer (variable name):
ChosenCategory
- Result: When a user selects "Electronics" (with code "ELEC"), the action stores "ELEC" into the
ChosenCategoryvariable. This variable can then be used to update a product list, showing only items belonging to the "Electronics" category.