Expand my Community achievements bar.

Adding columns in a dynamic table

Avatar

Level 1

I have created a table that allows users to add or delete rows as needed. Each row and column also contains scripting to automatically sum all the data entered into the table. Everything works great except one thing - any new rows added by the user aren't being calculated into the column totals. The new rows do calculate correctly into the row totals. Did I do something wrong here? I've attached my table so you can see what I've done.

http://tinyurl.com/23a6wz5

4 Replies

Avatar

Former Community Member

I see two issues.

1. On your calculations you are using the [*] notation to get all occurances of the field. The subform or RowName is what has the occurance on it not the individual fields....so remove the [*] from the C1, P1 etc... fields.

2. When you add a dynamic subform you have to get the fields that were created registered so that when the calcualtion fires it knows that those new fields are there. So on each addrow or remove button add this line of code to the end of your script:

xfa.form.recalculate(1)

Hope that helps

Paul

Avatar

Level 1

Thanks so much for the reply! This worked, but only for the first row. The

other six rows still have the same problem. Is there anything else I can do?

Also, I noticed that when I removed a row with data in it, the column totals

did not recalculate and subtract out the numbers from the row I removed. Any

ideas on how to fix this?

......

Quinn

Avatar

Former Community Member

I modified the calculation for the totals to do a sum of each of the repeating sections. I also added the recalculate

command to each of the buttons. Now it works the way you want ....I think!

See the modified attched file.

paul

Avatar

Level 1

This works perfectly - thanks so much, I really appreciate it!

......

Quinn