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."
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
Solved! Go to Solution.
Views
Replies
Total Likes
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
Views
Replies
Total Likes
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")
Oops I dont know how that ended up being different when I put it on here but they are the same in my form (like how you put it with the item(i) instead of the brackets)
And the weird thing is, I do not get any errors at all when previewing the form, or checking script syntax. I notice that I do get this error using the java console in the preview:
ReferenceError: This is not defined
12:XFA:form1[0]:total[0]:LABORTotal[0]:calculate
Not sure what it means though, any ideas?
Thanks!
Views
Replies
Total Likes
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.
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.
Views
Replies
Total Likes
Sorry guys, havent been able to upload the form until now because of some computer issues. Got them squared away now.
Here is the form:
https://acrobat.com/#d=Jvsh1CiwII1jl6FibSC3fA
Not 100% how my form is because I took out some of our companies information and whatnot, but the fields/scripts in question are all there.
Thanks agian for your help
Views
Replies
Total Likes
Ahhhh you know what I didnt catch that. But after correcting that it did not correct the issue "/
Views
Replies
Total Likes
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
Views
Replies
Total Likes
Niall,
Wow I know I clicked that when I was trying another route, but I forgot to unclick it. Cant belive it was that simple. Thanks for your help!
Considered solved!
Thanks again!
Views
Replies
Total Likes
Views
Likes
Replies
Views
Likes
Replies