iFormBuilder JavaScript Tips & Tricks
Table of Contents
What is the Date-Time element?
The Date-Time element allows the user to combine the functionality of both the Date and Time elements.
PLEASE NOTE: The following instructions assume you know how to add the Date-Time element to your form. If you do not, please follow the instructions HERE.
How do I dynamically populate the Date-Time element?
Using Page Level JavaScript, you can dynamically populate the Date-Time element. In order to do so, please follow the instructions below.
PLEASE NOTE: This functionality currently only works on iOS.
STEP 1. With your form loaded in the Form Builder, click the Page Level JavaScript icon.
STEP 2. You must first declare your variable. This can be named whatever you like. In this example, we'll be using myTime.
STEP 3. Enter your legal JavaScript function. In this example it will be var myTime = new Date(1988,3,12,6,30,0);. The date parameters in the example below will reflect a date and time of April 12, 1988, 6:30 am.
Each number represents a different aspect of time.
- 1988 - The year.
- 3 - The month. Note that the number used for the month is an index value which starts at 0. So while April is the 4th month, its index value is 3.
- 12 - The day of the month.
- 6 - The hour of the day. Note that this number is based on a 24-hour clock. So this will reflect 6 am. If you wanted 6 pm, this number would be 18.
- 30 - The minutes of the hour.
- 0 - The seconds of the minute.
PLEASE NOTE: This will work on both the Date and Time elements individually, but will only use the numbers that are applicable. For instance, the Time element would only reflect 6:30 am.
STEP 4. Click Save then Close.
STEP 5. In the Dynamic Value field of the element, place your variable.
STEP 6. Save your form.
STEP 7. Test the functionality on your device.
Comments
0 comments
Please sign in to leave a comment.