Hi,
I am creating a form which has a dynamic interactive sub form.
I want the sub forms to be numbered, i.e. first one is 1, second - 2, and every time a user adds or removes an instance, the sub forms are numbered consecutively.
How do I do this??
Thanks in advance for your replies.
Solved! Go to Solution.
Views
Replies
Total Likes
Here is a sample file for you..
https://acrobat.com/#d=gAGLpR7ETsBvowyLBIzcMA
I placed the below code in the LayOut Ready event of the TextField to display the Repeating Subform's index..
this.rawValue = this.parent.index;
And in the Remove Instance Button Click event:
Subform1.instanceManager.removeInstance(this.parent.index);
xfa.form.recalculate(0); // Passing 1 also to this method works.
Hope this helps.
Thanks
Srini
Views
Replies
Total Likes
Use the index of the Repeating Subform and add 1 to it. Because the index starts with 0.
For example if you have the text box inside a Subform that repeats..
this.rawValue = this.parent.index + 1;
Here the text box is one level down of the Repeating Subform in the heirarchy..If it is two levels down use this.parent.parent.index.. And so on..
Thanks
Srini
Thanks Srini, that’s great, works well.
The part I was having most trouble with was how to get the sub forms to re-number;
i.e. If I have 3 instances numbered 1, 2 and 3 and I delete 2, I want instance number 3 to re label to become the new 2.
Views
Replies
Total Likes
You need to add xfa.form.recalculate(1); to your add/remove scripts.
Views
Replies
Total Likes
Thanks
My scrip already has this line in. This line does sort the count for new additions post removal; it does not recalculate the count numbers of any instances added before the removal..........
i.e. I have instance A with label 1
I click the add button twice giving instances B and C with labels 2 and 3.
I click remove on instance B.
I am left with A and C with labels 1 and 3
I then click add and I now have A, C & D with labels 1, 3 & 3.
I need to get instance C to recalculate from 3 to 2
Views
Replies
Total Likes
Here is a sample file for you..
https://acrobat.com/#d=gAGLpR7ETsBvowyLBIzcMA
I placed the below code in the LayOut Ready event of the TextField to display the Repeating Subform's index..
this.rawValue = this.parent.index;
And in the Remove Instance Button Click event:
Subform1.instanceManager.removeInstance(this.parent.index);
xfa.form.recalculate(0); // Passing 1 also to this method works.
Hope this helps.
Thanks
Srini
Views
Replies
Total Likes
Great stuff thanks
Views
Replies
Total Likes
Views
Likes
Replies
Views
Likes
Replies
Views
Likes
Replies