Expand my Community achievements bar.

Dive into Adobe Summit 2024! Explore curated list of AEM sessions & labs, register, connect with experts, ask questions, engage, and share insights. Don't miss the excitement.
SOLVED

How to set 1st number in row = 10, and increment by 10 every time Button to Add new row is pressed. Also allow users to enter generic numbers, i.e 13 and still increment by 10 to be 23 or whatever.

Avatar

Level 1

How to set 1st number in row = 10, and increment by 10 every time Button to Add new row is pressed. Also allow users to enter generic numbers, i.e 13 and still increment by 10 to be 23 or whatever.

I already have my table set up with a Button that will add new rows when pressed.

I now want to specify that the 1st row is 10 and any other rows after that increment by 10. This will also allow users to enter any number they'd like and the next row will increment by 10.

Help please.

1 Accepted Solution

Avatar

Correct answer by
Level 10

Try changing the add row button to have the following JavaScript

var newRow = Table1._Row1.addInstance()

if (newRow.index > 0)

   newRow.NumericField1.rawValue = newRow.resolveNode('Row1[-1].NumericField1').rawValue + 10;

}

You will have to change this code to match your form names, but basically the addInstance() method will return the new row, the newRow.resolveNode('Row1[-1]... will get the value of the previous row and then we add 10.

Regards

Bruce

View solution in original post

3 Replies

Avatar

Correct answer by
Level 10

Try changing the add row button to have the following JavaScript

var newRow = Table1._Row1.addInstance()

if (newRow.index > 0)

   newRow.NumericField1.rawValue = newRow.resolveNode('Row1[-1].NumericField1').rawValue + 10;

}

You will have to change this code to match your form names, but basically the addInstance() method will return the new row, the newRow.resolveNode('Row1[-1]... will get the value of the previous row and then we add 10.

Regards

Bruce

Avatar

Level 1

Hi Bruce,

I am very new with LiveCycle Designer and appreciate your response very much.

For the add row button, can you specify where to put this script? I put the script into the "click*" area and also changed the table name to match my own but I am not getting it to work when I Preview PDF.

-Nancy

Avatar

Level 1

Hey Bruce,

Thanks so much for your code! It worked! I did some minor tweeking.

var newRow = Main.JPTaskDesc._Row1.addInstance(1)

if (newRow.index > 0)

{

   newRow.NumericField1.rawValue = newRow.resolveNode('Row1[-1].NumericField1').rawValue + 10;

}

and this worked perfectly. I cannot thank you enough! Thanks again.

-Nancy