instantmanager count not work in javascript

Avatar

Avatar

aka44356106

Avatar

aka44356106

aka44356106

20-10-2019

i have a table in dynamic form with two row and a button to add inatance in second row

second row initial count set to zero

i copy both row data in a  text-field

i set initial count for second row 0

var fields = xfa.resolveNodes("Table6.Row2[*].Cell1");

var total = 0;for (var i=0; i <= fields.length-1; i++)

{total = total + fields.item(i).formattedValueValue;}

this.rawValue = Table6.Row2.instanceManager.count ==0 ? "(i) Item 1" + xfa.resolveNode("Table6.Row1.Cell").formattedValue : "(i) itme1 " + xfa.resolveNode("Table6.Row1.Cell1").formattedValue + "\n(ii) item2 " + total;

but it not worked and always show second row data

plz help to correct script

Accepted Solutions (1)

Accepted Solutions (1)

Avatar

Avatar

radzmar

MVP

Total Posts

2.6K

Likes

386

Correct Answer

485

Avatar

radzmar

MVP

Total Posts

2.6K

Likes

386

Correct Answer

485
radzmar
MVP

25-10-2019

So far ist not clear, what kind of field your're using. And your script has some flaws or typos  – see the comments.

var fields = xfa.resolveNodes("Table6.Row2[*].Cell1");

var total = 0;

// a property "formattedValueValue" does not exist

// What type of field is Cell1 – text or numeric?

for (var i=0; i <= fields.length-1; i++) {

total = total + fields.item(i).formattedValueValue;

}

// Is it "Table6.Row1.Cell" or "Table6.Row1.Cell1"?

// What type of field is it – text or numeric?

this.rawValue = Table6.Row2.instanceManager.count == 0 ? "(i) Item 1" + xfa.resolveNode("Table6.Row1.Cell").formattedValue

: "(i) itme1 " + xfa.resolveNode("Table6.Row1.Cell1").formattedValue + "\n(ii) item2 " + total;

However, I guess this should do the trick.

var oRow2Cells = xfa.resolveNodes("Table6.Row2[*].Cell1"),

oRow1Cell = xfa.resolveNode("Table6.Row1.Cell1"),

nTotal = 0,

i;

for (i = 0; i < oRow2Cells.length; i += 1) {

nTotal += parseFloat(oRow2Cells.formattedValue);

}

this.rawValue = "(i) Item 1" + parseFloat(oRow1Cell.formattedValue) + (oRow2Cells.length > 0 ? ("\n(ii) item2 " + nTotal) : "");

Answers (0)