Skip navigation
SBRCA
Currently Being Moderated

Dynamic Table with repeating Subform

Jul 11, 2012 3:04 PM

Hello,

 

I am maiking a form which has a Dynamic Table with a repeating Subform.  The repeating subform has a dropdown list field which has three options for the user to pic.  "LABOR", "EQUIPT.", & "MATL."

1.png

 

The way I want the form to work is the user will choose which item they want to add to the form with the dropdown list.  Whatever amount they put into the "Amount" column will go to the corresponding total "LABORTotal", "EQUIPTTotal", & "MATLTotal"

 

The repeating Subform is basically the Row1, but I have the table split up into subforms because of issues I had eariler with the form.  The repeating subform title is "detail". 

 

I cannot get the sums for the 3 items to go into the corresponding totals field.  This is the script that I have for the labor total field:

 

form1.total.LABORTotal::calculate - (JavaScript, client)

var nAmount = xfa.resolveNodes("detail[*].Table1.Row1.AMOUNT");

var nItem = xfa.resolveNodes("detail[*].Table1.Row1.ITEM");

var nSum = 0;

 

for (var i=0; i<nAmount.length; i++)

{

    if (nItem.item[i].rawValue == "LABOR")

    {

    nSum = nSum + nAmount.item(i).rawValue;

    }

}

This.rawValue = nSum;

 

I am not familiar with loop scripting or var scripting so I know I am getting it wrong somewhere. 

 

I would greatly appreciate any help!

 

Thanks

 
Replies
  • Currently Being Moderated
    Jul 11, 2012 11:09 PM   in reply to SBRCA

    Hi,

     

    do you get any errors in the JavaScript Console when you test the form in Acrobat?

    I think the there is one of because of this line:

     

    if (nItem.item[i].rawValue == "LABOR")

     

    which should be:

    if (nItem.item(i).rawValue == "LABOR")

     
    |
    Mark as:
  • Currently Being Moderated
    Jul 12, 2012 5:27 PM   in reply to SBRCA

    Hi,

     

    It might be a pasting issue into the forum, but "This", should be "this".

     

    Hope that helps,

     

    Niall

     

    PS: this is on line 12 of the script.

     
    |
    Mark as:
  • Currently Being Moderated
    Jul 12, 2012 11:30 PM   in reply to SBRCA

    Hi,

     

    if possible for you, share your form with us.

    It will make it easier for us to find the bugs.

     

    You can use Acrobat.com to upload your form.

     
    |
    Mark as:
  • Currently Being Moderated
    Jul 16, 2012 1:43 PM   in reply to SBRCA

    Okay,

     

    Here is your form back to you: https://acrobat.com/#d=IA67zcTBrWlnpcYS234*XQ.

     

    The issue wasn't the script. If you select the dropdown and go to the Object > Binding palette, you will see you had ticked "Specify values" and these were set to 1, 2 and 3.

     

    This meant that if the user selected LABOR, the value of the dropdown was "1" and NOT "LABOR". This was throwing the if statement.

     

    I deselected the specify values and it worked as expected.

     

    Hope that helps,

     

    Niall

     
    |
    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