Skip navigation
Currently Being Moderated

Expandable Table Need to Sum Different Cost Centers

May 1, 2012 12:09 PM

I am trying to complete a mileage reimbursement form. I think I have a good design (?) but I am missing a critical efficiency within the form. I want the form to be able to calculate the cost centers across the expandable table within the subform. I have a dropdown that has different cost centers. How would I be able to sum like cost centers within the expandable table? Can I populate another table with just the totals for a particular cost center by calculation? I would need this for all cost centers This would help out the accounting department as the mulitple cost centers would be added.


My first page is expandable to accomodate multiple rows and has a page total and a grand total that floats if more rows are needed. My second page is more or less just for accounting I have a seperate table that right now is manually completed. The clerk has to printout the form and then manually add each cost center and then add it to the table on the second page.


I have tried to just use a numeric field on the second page attempting to get the calculations based of the test entry in the cost center of Edit. It only places the data of the first entry and does not cycle through and capture all cost centers in the expandable table that are Edit. Any help in the code and ideas on how to present the total in a new table would be greatly appreciated.I am a beginner at this and am trying to learn and complete this on my own but I am not sure what to do. Attached is my form.

  • Currently Being Moderated
    May 1, 2012 3:12 PM   in reply to wilsons062103

    The following JavaScript will loop through the table and total up according to what is selected in the dropdown list. Put it on the Calculate event of a numeric field.


    You'll need a separate field for each category and you'll need to update the rawValue test to the appropriate number for each field (I started with 2 because your first entry, which is 1 is blank). Depending where you put the fields you'll need to update the path to "Table1".


    var nTotal = 0;

    for (var i=0; i < Table1._Item.count; i++){

         if (xfa.resolveNode("Table1.Item[" + i + "].DropDownList2").rawValue == 2){

              nTotal ++;



    this.rawValue = nTotal;


    Couple of tips:

    You've got an extra subform on your "page 3", you've wrapped one subform with another which isn't needed.


    It's important to name your subforms, especially when scripting.

    Mark as:
  • Currently Being Moderated
    May 1, 2012 3:41 PM   in reply to wilsons062103



    Looks like me and Jono were looking at this at the same time. I put the summary in another table is probably the only real difference, but having made a sample I thought I might as well share it,  Have a look at the code in the form1.SummaryTable calculate event.


    Hope it helps



    Mark as:
  • Currently Being Moderated
    May 2, 2012 6:34 AM   in reply to BR001

    So was I. I wanted to help out with this one because I JUST got finished creating a similar form that had me pulling my hair out.



    But I like BR001's better because you don't have that extra page added as it is in mine.



    Mark as:
  • Currently Being Moderated
    May 2, 2012 10:30 AM   in reply to BR001

    That's slick Bruce!

    Mark as:

More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points