These forums are now Read Only. If you have an Acrobat question, ask questions and get help from one of our experts.

Incrementing numbers in dynamic rows

hattg
Registered: Jun 18 2009
Posts: 36

I have a form which has dynamic rows, added by clicking an add button. What I would like to do, is to have a column that has a row number, starting with 1, which increments up when a new row is added, but also would increment down if a row was deleted.

It is set up to be able to delete any row, so any number above a deleted row would need to increment down one, while obviously the ones below would stay the same.

Just for clarity sake, if I add rows to have 5, numbered 1 to 5, and row 3 is deleted, rows 4 and 5 would need to increment down one while rows 1 and 2 would remain the same. The end result is that the rows are always numbered in sequential order.

Thanks

My Product Information:
LiveCycle Designer, Windows
radzmar
Expert
Registered: Nov 3 2008
Posts: 1202
Hi,

that can simply be done.
Add a nummeric field to your row with this JavaScript in its calculate:event.

this.rawValue = this.parent.index +1;

radzmar
LoveCycle Blog
Documents you need:
LiveCycle Designer ES2 Docs

hattg
Registered: Jun 18 2009
Posts: 36
Thanks, and that works for adding the numbers, but I also need it to renumber whenever a row is deleted.

Right now it will just delete that row and all the numbers after remain the same, so there is a gap between numbers. I need the numbers to remain sequential, even after a row is deleted.
radzmar
Expert
Registered: Nov 3 2008
Posts: 1202
Therefore you shold add this code into the click:event of your button, that deletes the row.

xfa.form.recalculate(1);

radzmar
LoveCycle Blog
Documents you need:
LiveCycle Designer ES2 Docs