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
BedrockMission!

Learn more

View all

Sign in to view all badges

SOLVED

instantmanager count not work in javascript

aka44356106
Level 4
Level 4

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

1 Accepted Solution
radzmar
Correct answer by
Level 10
Level 10

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) : "");

View solution in original post

1 Reply
radzmar
Correct answer by
Level 10
Level 10

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) : "");

View solution in original post