Need a script to add to an "add" row button and also keep information entered in some of the columns | Community
Skip to main content
Level 5
May 14, 2022 11:22 AM UTC
Solved

Need a script to add to an "add" row button and also keep information entered in some of the columns

Good day,

 

Please help me to resolve this.  I cannot locate a script for what I would like to do.  I have a table that has a button to add a row and a button to remove a row.  I would like to add a button to add a row and keep whatever information that was entered in some of the columns.  Is there a script I can add to the button to accomplish this?  I cannot use the global function  of the columns because sometimes the user will need to add different information in the columns when a blank row is added.

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
radzmar
radzmarAccepted solution
Level 10
May 16, 2022 7:41 PM UTC

Use the response method to ask the user, how many rows to add.

var cInput = xfa.host.response("Enter number of rows you want to add:", "Add rows", "1", false),
	n = parseInt(cInput, 10) > 0 ? parseInt(cInput, 10) : 1,
	i = 0;
for (i; i < n; i += 1) {
	_Row1.addInstance(true);
}

7 replies

Mayank_Gandhi
Employee
May 15, 2022 8:02 AM UTC

" keep whatever information that was entered in some of the columns."- Please elaborate on this, because adding a row will add a new blank row you could set the new data using instance Manager API.

Translate
Level 5
May 15, 2022 12:00 PM UTC

Thank you for letting me to explain further.  I would like my form to allow the user to duplicate entries that were entered in specified columns when they add a new row with a click of a button.  Example:  Row 1, Column B has a date entered.  When the user clicks the button to add an additional row (Row 2), I want the same date in Row 1, Column B to be in Row 2, Column B. That way they will not have to enter the information manually over and over again. 

Also, on a separate question, is there a way to add a specified number of rows when your form starts with one row?  Example:  My form starts with one row, which is needed, but sometimes, my form can have hundreds of rows.  The number of rows needed is known in advance.  Can I create a button for the user to click that will allow them to enter a number and then the form will create that number of rows that they entered?   This is for Livecycle designer.

Translate
radzmar
radzmarAccepted solution
Level 10
May 16, 2022 7:41 PM UTC

Use the response method to ask the user, how many rows to add.

var cInput = xfa.host.response("Enter number of rows you want to add:", "Add rows", "1", false),
	n = parseInt(cInput, 10) > 0 ? parseInt(cInput, 10) : 1,
	i = 0;
for (i; i < n; i += 1) {
	_Row1.addInstance(true);
}
Translate