iFormBuilder JavaScript Tips & Tricks
Table of Contents
- What is a Select element?
- What is a Pick List element?
- How Do I Dynamically Populate a Pick List or Select Element?
- Download the Form Package
Also, check out:
What is a Select element?
The Select element is used in conjunction with an Option List. It allows a user to select only one of the options in the list. Use this element when you have small lists and short options to work with.
Click here for more information on how to add a Select element to your form.
What is a Pick List element?
The Pick List allows users to choose options from a predefined list known as an Option List. It displays as a dropdown menu on mobile devices.
Click here for more information on how to add a Pick List element to your form.
How do I pre-populate a Select or Pick List element?
In this article, we'll use a Pick List element but you can follow the same steps for Select elements.
Please follow the instructions below.
STEP 1. From inside your form, add a Pick List element
In this example, we'll name the form: zerion_prepopulate_picklist and the Pick List: employee
STEP 2. Assign an option list to the element
PLEASE NOTE: The options in this Pick List example will be:
STEP 3. Let's say we want option Lisa Smith (Sort Order: 3; Key Value: lisa_smith) to be populated every time users open the form.
In the Dynamic Value field, put the following JavaScript:
3.A. Using Sort Order
zerion_prepopulate_picklist.employee = 3
3.B. Using Key Values
zerion_prepopulate_picklist.employee = "lisa_smith"
STEP 4. Save your form.
STEP 5. Test the functionality on your device.
Download the form package below to use as an example.
Comments
1 comment
If I am trying to use the key value in section 3.B. but the key value is a number, it is ignoring the "" and treating it like a sort order.
Please sign in to leave a comment.