Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
BedrockMission!

Learn More

View all

Sign in to view all badges

How to populate form dropdown with values depending on previous dropdown value?

Avatar

Avatar
Contributor
Level 2
jezwn
Level 2

Likes

9 likes

Total Posts

69 posts

Correct Reply

2 solutions
Top badges earned
Contributor
Shape 1
Springboard
Establish
Validate 1
View profile

Avatar
Contributor
Level 2
jezwn
Level 2

Likes

9 likes

Total Posts

69 posts

Correct Reply

2 solutions
Top badges earned
Contributor
Shape 1
Springboard
Establish
Validate 1
View profile
jezwn
Level 2

27-12-2019

I've got this 3 dropdown fields, month, day and year. Upon selection of a specific month the day dropdown field should be populated with exactly the number of days for that particular month. Similiary it should be accountable for leap years as well. How to do that in AEM Forms?

form validation

Accepted Solutions (1)

Accepted Solutions (1)

Avatar

Avatar
Contributor
Level 2
jezwn
Level 2

Likes

9 likes

Total Posts

69 posts

Correct Reply

2 solutions
Top badges earned
Contributor
Shape 1
Springboard
Establish
Validate 1
View profile

Avatar
Contributor
Level 2
jezwn
Level 2

Likes

9 likes

Total Posts

69 posts

Correct Reply

2 solutions
Top badges earned
Contributor
Shape 1
Springboard
Establish
Validate 1
View profile
jezwn
Level 2

27-02-2020

In the code editor for day use the following logic,

 

function getDates(numberOfDays) {
var dates = [];
var toDates;
for (var i = 1; i <= numberOfDays; i++)
{
if (i < 10) {
toDates = "0" + i + "=0" + i;
dates.push(toDates);
} else {
toDates = i + "=" + i;
dates.push(toDates);
}
}
return dates;
}

if (birthMonth.value == "January" || birthMonth.value == "March" || birthMonth.value == "May" || birthMonth.value == "July" || birthMonth.value == "August" || birthMonth.value == "October" || birthMonth.value == "December") {

this.items = getDates(31);
} else if (birthMonth.value == "February") {
this.items = getDates(29);
} else {
this.items = getDates(30);
}

Answers (1)

Answers (1)

Avatar

Avatar
Springboard
Level 10
Mayank_Gandhi
Level 10

Likes

310 likes

Total Posts

1,139 posts

Correct Reply

184 solutions
Top badges earned
Springboard
Establish
Validate 1
Contributor 2
Ignite 5
View profile

Avatar
Springboard
Level 10
Mayank_Gandhi
Level 10

Likes

310 likes

Total Posts

1,139 posts

Correct Reply

184 solutions
Top badges earned
Springboard
Establish
Validate 1
Contributor 2
Ignite 5
View profile
Mayank_Gandhi
Level 10

05-01-2020

why don't you use Date Picker component?