Dropdown generates 'month' subforms

Avatar

Avatar
Validate 1
Level 1
stephenf8734174
Level 1

Like

1 like

Total Posts

45 posts

Correct reply

0 solutions
Top badges earned
Validate 1
Boost 1
Applaud 5
View profile

Avatar
Validate 1
Level 1
stephenf8734174
Level 1

Like

1 like

Total Posts

45 posts

Correct reply

0 solutions
Top badges earned
Validate 1
Boost 1
Applaud 5
View profile
stephenf8734174
Level 1

14-03-2016

I need a form that includes a dropdown list with a 'months' list - once a month is selected subforms for that month plus the next 2 appear. This form will then be printed for clients to mark particular results on each date. Is this possible, and would the form have to be updated regularly to allow for changes to the months? Thanks.

Accepted Solutions (0)

Answers (1)

Answers (1)

Avatar

Avatar
Validate 1
Level 4
MinusZero
Level 4

Likes

30 likes

Total Posts

326 posts

Correct reply

54 solutions
Top badges earned
Validate 1
Boost 5
Boost 3
Boost 25
Boost 10
View profile

Avatar
Validate 1
Level 4
MinusZero
Level 4

Likes

30 likes

Total Posts

326 posts

Correct reply

54 solutions
Top badges earned
Validate 1
Boost 5
Boost 3
Boost 25
Boost 10
View profile
MinusZero
Level 4

30-03-2016

Hi,

This will be a start for you.

if ($.boundItem(xfa.event.newText) == "Jan") {

  this.resolveNode('Project._MySubform').addInstance(1);

  if (xfa.host.version < 😎 {

      xfa.form.recalculate(1);

  }

  this.resolveNode('Project._MySubform').addInstance(1);

  if (xfa.host.version < 😎 {

      xfa.form.recalculate(1);

  }

  this.resolveNode("MySubform[1].TextField1").rawValue = "February"; //adds to first new subform field

  this.resolveNode("MySubform[2].TextField1").rawValue = "March"; //adds to second new subform field

}

Add this to a change event of a dropdownlist.

When "Jan" is selected, a new instance is created of MySubform and February is inserted into the first new instance of the subform (MySubform[1]). Javascript starts with a zero base, so if the new instance isnt specified, it will be placed in the original form. Subforms can be a pain and they have given me much stress over the years. I hope this gives you a start.

This is simple enough to do with the Action Wizard also.

1. Add Action to dropdownlist

2. Condition: When dropdownlist1 "textselected" is Jan

3. Result: Add a New Instance - select your subform - do this twice

4. Result: Set the Value of a Field - select the field you want the month, add the next month eg February, March - do this twice.

5. Click ok.

After it is done, simply edit the code to add [1] and [2] as shown above. this will insert text into the correct form.