I have a table that currently consists of 3 rows.
Bag | Number of Items in Bag |
---|---|
A | 6 |
B | 12 |
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!
Solved! Go to Solution.
Views
Replies
Total Likes
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.
Views
Replies
Total Likes
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.
Views
Replies
Total Likes
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[*])Views
Replies
Total Likes
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[*].
Views
Replies
Total Likes
The total field is in the table, it is in the footer row. The calculation is occuring in the total field.
Views
Replies
Total Likes
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
Views
Replies
Total Likes
Views
Likes
Replies
Views
Likes
Replies