


johnh86027037
johnh86027037
03-05-2018
I am creating a dropdown list - where users can choose the proper year of business.
This dropdown needs to be customized to the user:
I want the current year to be calculated instead of static.
How do I add values to a dropdown list?
In LiveCycle - I would do something like this:
for (var i=dateBaseYear.rawValue; i<=dateCurrentYear.rawValue; i++)
{
//console.println(i);
this.addItem("" + i); //needed to add a string in front of 'i'. not sure why
}
Is there a similar solution for AEM Forms?
Mayank_Gandhi
Mayank_Gandhi
03-05-2018
Hi John,
I guess you are working with adaptive forms, you should use rule editor to set the values in drop-down list. Please refer Adobe Experience Manager Help | Adaptive forms rule editor.
Thanks,
Mayank
johnh86027037
johnh86027037
03-05-2018
I have saved the Guide and refer to it constantly.
Is there an example that I can reference? I cannot seem to find out to add each value - via the rule editor.
Thanks
Mayank_Gandhi
Mayank_Gandhi
03-05-2018
I will create some sample script and share with you shortly.
johnh86027037
johnh86027037
15-05-2018
Mayank,
Any progress? Looking forward to seeing an example.
Thanks
John
Mayank_Gandhi
Mayank_Gandhi
24-08-2018
Hi John,
Somehow I missed this thread, did you got this sorted out already?
DarrenBiz
DarrenBiz
26-08-2018
The DropDownList can be programmatically populated in the initialise event using an array of key=value pairs [1] on the items property [2]. So for your particular example, to populate the list starting at the current year and running for 5 years would look something like:
(on the initialise event)
var currentYear = (new Date()).getFullYear();
this.items = [];
for (var i = 0 ; i < 5 ; i++) {
this.items.push(i + "=" + currentYear-- + " Item Name");
}
The above code will add 5 entries to the drop down list
0=2018 Item Name
1=2017 Item Name
...
4=2014 Item Name
When the item is selected, the key will be stored in the field property. If you want the value stored instead, then just leave out the key= part to the item string when you are adding it to the items array.
[1] Adobe Experience Manager Help | Adaptive Form Expressions