Expand my Community achievements bar.

Automatic numbering of rows/subforms

Avatar

Former Community Member
I want to make a form where users can add and remove subforms/table rows, and where every subform/table row is numbered automatic in the first column.



Example:

1 TEXT

1.1 text

1.2 text

1.3 text



2 TEXT

2.1 text

2.2 text

2.3 text

2.4 text



3 ETC.

3.1 etc.



I want the numbers to be calculated automatic.



I know how to make the add/remove subform/table row. That isn't the problem. I just don't know how to make the fields calculate the numbering.

And I don't know if the whole thing should be a table, or that I have to add a subform (with a table included) for every whole number, with the whole number row as a header and the following numbers as rows to be added.



Can anyone help me with this?



Thanks in advance!



Sterre
5 Replies

Avatar

Level 5
I have done some thing similar to this using 'index' property of dynamic subform. I your case you may have to use subform (child) in a subform (parent). And when displaying the number trap the value of index respect to the current position and then concat them then display. For example code should look similar to



in the initailize event:: JS code.

var Cindex, Pindex

Pindex = this.parent.parent.index;

Cindex = this.parent.index;



this.rawValue = Pindex+"."+Cindex;

Avatar

Former Community Member
Here is what I use when I want to auto number rows in a table or table like set up using subforms



//Use this in the calculate event of a text field in a table row or sub form. As new rows are added they will be auto numbered.



var myNum = tableRow or subform.index;

this.rawValue = myNum + 1;



//NOTE: You must also use the recalculate method when you are removing rows/sub forms so the number in the fields will readjust.

//Add this line after the line or code when adding or removing row or sub forms.



xfa.form.recalculate(1);

Avatar

Former Community Member
Hi Sterre,

I am new to adobe forms. I seen your requirement, thats seems to be very useful in my future. Can i 've the procedure to solve that req.

Thanks in advance.



Regards

phalani

Avatar

Former Community Member
Sterre - I've just found the fix for my similar problem....see if this script works for you:



this.rawValue = (parent.parent.index) + 1 +((Row3.index+1)/10);



Obviously, change out the reference name ("Row3") to match yours.

Avatar

Former Community Member
//Use this in the calculate event of a text field in a table row or sub form. As new rows are added they will be auto numbered.



//Change "table row" or "subform" to the real name of which ever one it is.

var myNum = table row or subform.index;

this.rawValue = myNum + 1;



//NOTE: You want to also use the recalculate method when you are removing rows/sub forms so the number in the fields will recalculate.



xfa.form.recalculate(1);



//Add the above line after the line of code when adding or removing row or sub forms.