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

Adding unlimited table rows to Dynamic PDF

jmarq
Registered: Jul 15 2010
Posts: 6
Answered

Forgive me for posting what may be a silly question for most. I am a newbie to scripting and Adobe Forms. I found some code to allow me to dynamically add rows to my form, but I do not know what to change in the code to allow me to add more than 7 rows. Can anyone point me in the right direction? Any help is greatly appreciated.

form1.#subform[0].Add::click - (JavaScript, client)
// nTableLength stores the number of XML elements contained in Table1.
var nTableLength = Table1.nodes.length;

// nNumRow is used to calculate the number of rows contained in Table1.
var nNumRow = 0;

// This script uses a For loop to cycle through all of the XML elements
// contained in Table1.
for (var nCount = 0; nCount < nTableLength; nCount ++) {

// If the current XML element in Table1 is of type subform and it
// is not a header row, then increment the variable nNumRow by one.
// If the table included a footer row, this script would have to
// account for it.
//
// Note: In the Adobe XML Form Object Model, all table rows are
// considered subform objects.
if ((Table1.nodes.item(nCount).className == "subform") & (Table1.nodes.item(nCount).name !== "HeaderRow")) {
nNumRow = nNumRow + 1;
}
}

// An if-else statement is used to prevent form fillers from adding
// more than the maximum number of seven rows to a table.
if (nNumRow == 7) {
xfa.host.messageBox("The maximum allowable number of rows is 7. You cannot add any more rows.", "Warning", 3);
}
else {

// This script uses the addInstance() method to add a new instance
// of the Row1 object contained in Table1.
Table1.Row1.instanceManager.addInstance(1);
}

My Product Information:
LiveCycle Designer, Windows
radzmar
Expert
Registered: Nov 3 2008
Posts: 1202
If you want to add a row to the table you only need this code:

Table1.Row1.instanceManager.addInstance(1);

radzmar
LoveCycle Blog
Documents you need:
LiveCycle Designer ES2 Docs

jmarq
Registered: Jul 15 2010
Posts: 6
Thanks for your help. I commented out all other code and now have unlimited rows. Such a simple answer. Thanks again.
rcwip
Registered: Oct 30 2010
Posts: 13
Hi there. I'm using Livecycle Designer ES v8.2. I'm trying to create an interactive PDF using Designer in which user can press a button to add rows to a table. I created a blank form with a table and a button both in a subform (flow content). Preview mode in Form property has been set to "interactive PDF". I have the following javascripts embedded in the button (mouseup) for user to add rows:

Table1._Row1.addInstance(1);
xfa.form.recalculate(1);

But when I previewed the form and press the button, nothing happened. Did I miss something? Thanks.

SLDC
Registered: Oct 25 2010
Posts: 70
I think you need

Table1._Row1.instanceManager.addInstance(1);

Also, you might be better off putting it in the button's Click event than in mouseUp.

Does that work?
avinash21
Registered: Aug 27 2009
Posts: 1
you want to Adding unlimited table rows to Dynamic PDF
you only need this code:
Table1.Row1.instanceManager.addInstance(1);
and set Row1 property ------- Reperat row for each data item check min count [1]