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

Avatar

nancytp

Avatar

nancytp

nancytp

26-02-2016

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.

Accepted Solutions (1)

Accepted Solutions (1)

Avatar

Avatar

_Bruce_Robertson

MVP

Total Posts

(val/1000)?string[".0"]}K

Likes

268

Correct Answer

371

Avatar

_Bruce_Robertson

MVP

Total Posts

(val/1000)?string[".0"]}K

Likes

268

Correct Answer

371
_Bruce_Robertson
MVP

26-02-2016

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

Answers (2)

Answers (2)

Avatar

Avatar

nancytp

Avatar

nancytp

nancytp

29-02-2016

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

Avatar

Avatar

nancytp

Avatar

nancytp

nancytp

29-02-2016

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