cancel
Showing results for 
Search instead for 
Did you mean: 

Copy the data from first line while dynamically adding a new line in table

nikhilkup
Active Participant
0 Kudos

Hi,

1. There is a table

2. An add button adds a new line to the table using 'AddInstance'

3. A record is entered in the first line

4. When the add button is clicked it adds a new line and along with it copies the data entered in the first line

My question is how to copy the data from the first line and show it in the new line added. This is required so that user can use most of the common values in the first line.

Thanks,

Nikhil

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

it's funny.. the first 2 times i created tables, this is exactly what happened to me - i would add a row and it would repeat the previous data... I finally figured out how to do it correctly and forgot how to do it "incorrectly"

nikhilkup
Active Participant
0 Kudos

Hi,

Yes i know that scenario, that happens when we assign a structure with single index. the problem in such scenarios is if we change in the next line the value in the first line to changes as they both have same index.

former_member226239
Contributor
0 Kudos

You can use the following Java Script in the Click event of the button.

// Get the number of rows in the table

var nrows = xfa.resolveNodes("page.table.DATA[*]").length;

// Add a new instance(row) to the table

page.table.addInstance.instanceManager(1);

xfa.form.recalculate(1);

// Copy the values from the first line to the newly created row

page.table.DATA\[ nrows \].field1.rawValue = page.table.DATA\[ 0 \].field1.rawValue;

..........field2

..........field3

Thanks,

Chandra Indukuri

Answers (1)

Answers (1)

OttoGold
Active Contributor
0 Kudos

Hello, You should read a little before scripting, start here:

http://www.adobe.com/devnet/livecycle/articles/lc_designer_scripting_basics/lc_designer_scripting_ba...

Note there is one very interesting chapter in the end (the last one;))

Regards, Otto