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

Dynamic table row number

Boon
Registered: May 5 2010
Posts: 66
Answered

Hi,

I am creating a dynamic form. I have a dynamic table with "ADD", and "REMOVE" buttons. The ADD button is at the bottom of the table and I have only 1 button. The REMOVE button is located on each of every row. When a user clicks ADD, a new row is added to the bottom of the table. When a user clicks REMOVE, that particular row is deleted.

On each row, I would like to have a column that shows the row number. (E.g. the column name would be something like "#", "Item"....)

The question is how can I make this row number dynamic? My idea is to get the row number of that row in a table, but I don't know what function to use to get a row number.

Thanks,
Boon

thomp
Expert
Registered: Feb 15 2006
Posts: 4411
The row number is the same as the instance, or index, number for the repeated subform. Use this code in a text box inside the repeated subform to get the row number.
this.rawValue = this.parent.index + 1;
if "this" is a pointer to the text box, then "parent" is a pointer to the subform that contains the text box and "index" is the instance number for that subform. The instance number is zero based, so add one to make the row number.

This code needs to be placed on an event that is called whenever the parent subform index changes. Then is an index change event, but it is unreliable in some situations. A better choice is the "layoutReady" event.

Thom Parker
The source for PDF Scripting Info
[url=http://www.pdfScripting.com]pdfscripting.com[/url]

The Acrobat JavaScript Reference, Use it Early and Often
[url=http://www.adobe.com/devnet/acrobat/javascript.php]http://www.adobe.com/devnet/acrobat/javascript.php[/url]

Then most important JavaScript Development tool in Acrobat
[url=http://www.pdfscripting.com/public/34.cfm#JSIntro][b]The Console Window (Video tutorial)[/b][/url]
[url=http://www.acrobatusers.com/tutorials/2006/javascript_console][b]The Console Window(article)[/b][/url]

Thom Parker
The source for PDF Scripting Info
www.pdfscripting.com
Very Important - How to Debug Your Script

Boon
Registered: May 5 2010
Posts: 66
Thanks Thomp! It works perfectly well!
Boon
Registered: May 5 2010
Posts: 66
Thomp,

I would like to learn more about "resolvenode". Where can I find a good material about this topic? I have seen many examples and don't quite understand. Sometimes they use a full path, some time they have"[*]" in the path,...

Thanks for your guideline.

Boon
thomp
Expert
Registered: Feb 15 2006
Posts: 4411
There are serveral LiveCycle scripting documents here:
http://kb2.adobe.com/cps/330/330467.php

You're interested in the "Scripting Object Model Reference". It's the last one on the page. The SOM is the input to both the resolveNode() and resolveNodes() fucntions, as well as several others. It's a bit cryptic, but every thing you need to know is there.

Thom Parker
The source for PDF Scripting Info
[url=http://www.pdfScripting.com]pdfscripting.com[/url]

The Acrobat JavaScript Reference, Use it Early and Often
[url=http://www.adobe.com/devnet/acrobat/javascript.php]http://www.adobe.com/devnet/acrobat/javascript.php[/url]

Then most important JavaScript Development tool in Acrobat
[url=http://www.pdfscripting.com/public/34.cfm#JSIntro][b]The Console Window (Video tutorial)[/b][/url]
[url=http://www.acrobatusers.com/tutorials/2006/javascript_console][b]The Console Window(article)[/b][/url]

Thom Parker
The source for PDF Scripting Info
www.pdfscripting.com
Very Important - How to Debug Your Script