Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
Bedrock Mission!

Learn more

View all

Sign in to view all badges

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

Avatar

Level 5

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.

5 Replies

Avatar

Level 10

" 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.

Avatar

Level 5

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.

Avatar

Level 10

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);
}

Avatar

Level 10

To copy data, use a for loop.

Given you have the following structure: Table1.Row1.Date and the Add button is located in the Row1 as well then this script will copy the date fields data to all following rows starting from the current one and where the date field is empty.

if (!Date.isNull) {
	var oRows = Table1.resolveNodes('Row1[*]'),
		j = this.parent.index,
		cDate = Date.rawValue;
	for (j; j < oRows.length; j += 1) {
		if (oRows.item(j).Date.isNull) {
			oRows.item(j).Date.rawValue = cDate;
		}
	}
}

 

 

Avatar

Level 10

@islandgirl23 If you want to add no. of rows based on user inputs just call addInstance inside a for loop on an exit of the field which takes user inputs. This for loop will run until the user entered the value. You can call it on form initialize as well.

 

user enters X

for(var i=0;i<X;i++){

addIn

}

 

https://help.adobe.com/en_US/livecycle/10.0/DesignerScriptingRef/WS92d06802c76abadb-3e14850712a151d2...