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
Bedrock Mission!

Learn more

View all

Sign in to view all badges

SOLVED

Adding up values in a repeting row

treesRansw
Level 2
Level 2

I have a table that currently consists of 3 rows.

BagNumber of Items in Bag
A6
B12
Total

I have a button which allows the user to add more rows to the table, a maximum of 10 rows can be added.  I would like to be able to add up all the numbers, in the total cell.  How do I add up all the numbers for cells that do not currently exist?

For example:  If today I have 2 bags..Bag A has 6 items in it and Bag B has 12 items in it.  But tomorrow I have 7 bags, each with a different number of items.

What is the code I can write in my total box that will add up the number of items in a bag, for up to 10 bags?  What I don't want is all 10 rows static on the page, if the table only needs to consist of 2 rows, that is all that I would like to see, and I don't want a big gap (8 rows) between my values and the total box.

I can share my form if necessary.

Any help would be appreciated....greatly!

1 Accepted Solution
cyndilynnrose
Correct answer by
Level 2
Level 2

You need to use Sum in the calculate event of the total field.

<calculate>

                        <script>Sum(Table1.Row1[*].items[*])

</script>

                     </calculate>

That's it.  It cycles through the rows every time you leave the items field and recalculates.

View solution in original post

5 Replies
cyndilynnrose
Correct answer by
Level 2
Level 2

You need to use Sum in the calculate event of the total field.

<calculate>

                        <script>Sum(Table1.Row1[*].items[*])

</script>

                     </calculate>

That's it.  It cycles through the rows every time you leave the items field and recalculates.

View solution in original post

treesRansw
Level 2
Level 2

Thank you for your response, that script isn't working.

I put in 5 for the first value, and 5 for the second, the total is coming up 5.

Here is my script: 

Sum(SeedItem1.Row2[

*].NumBushels[*])

cyndilynnrose
Level 2
Level 2

What field are you adding the calculate event to?  Is the total field inside the same table as the rows you're counting?

I double-checked my code (that works in Acrobat and Reader), and I have quite a few calculate fields.  The only scripting I used for any of it was that tiny bit - table_name.row_name[*].cell_name[*].

treesRansw
Level 2
Level 2

The total field is in the table, it is in the footer row.  The calculation is occuring in the total field.

treesRansw
Level 2
Level 2

I figured it out.....I had changed the name name of Row2[1] to Row 3...problem fixed, I just changed Row3 back to Row2[1].

Thanks