Expand my Community achievements bar.

SOLVED

New to LiveCycle- need help adding forms together (calculations)

Avatar

Level 2

Okay, here's my scenario.

I have one field called RoomBoard, one below it called TuitionFees.  I'm looking to calculate both automatically in a "Total" field below it so that when a person puts a figure in for Room & Board and one in for Tuition & Fees, a total will automatically pop up.  I thought this would be simple, but I just can't get it! HELP!

1 Accepted Solution

Avatar

Correct answer by
Level 6

Change the type of all three fields to numeric.  Highlight each field and in the Object window, on the Field tab, pull down the Type dropdown and select "Numeric Field".

View solution in original post

25 Replies

Avatar

Employee

Assuming you are using LiveCycle Designer 8.X, a quick search in the Help system (F1) for "Calculating sums of fields" revealed detailed instructions.

Hope this helps,

Marc.

Avatar

Level 2

I've got verson 8.2, but I'm assuming that wouldn't change something like this.  I went to help on the topic you provided, but it helps with calculations for repeating fields, and not 2 different fields.  I do not understand script at all, so I'm just kind of lost....

Avatar

Level 6

If you can post your form we'll explain what needs to be done.

Avatar

Level 2

Okay, here it is.  On page 4, where it says "Room & Board", "Tuition and Fees" and "Total", I'd like the "Total" field is adding Room and Board and Tuition and Fees together automatically as a student puts numbers in the fields..

Then, below it in the larger section of that page, I want to add each field so that the "TOTAL" field at the bottom is a grand total of each amount added.

Also, are my fields for dollar amounts correct?  Is there a different way I should be formatting them?

I'm sorry... I'm all about WYSIWYG--this script stuff is Greek to me...   Thanks in advance for your help!!!!!!

Avatar

Level 2

Okay, here it is.  On page 4 at the top, I want "Room and Board" and "Tuition and Fees" to automatically add in the "Total" field.

While we're at it, in the section below that, I want all of the figures to tally into the big "Total" box at the bottom.

Should I be using a special-designed field for dollar amounts, or is what I'm doing okay?

Sorry, I enjoy WYSIWYG... this stuff is all Greek to me.   Thanks in advance for your help!!!!

Avatar

Level 2

Okay, here it is. On page 4 at the top, I want "Room and Board" and

"Tuition and Fees" to automatically add in the "Total" field.

While we're at it, in the section below that, I want all of the figures

to tally into the big "Total" box at the bottom (other than the info in

the section above it).

Should I be using a special-designed field for dollar amounts, or is

what I'm doing okay?

Sorry, I enjoy WYSIWYG... this stuff is all Greek to me. Thanks in

advance for your help!!!!

Avatar

Former Community Member

There are numerous ways to do this. One way to get this working is to make sure all these fields are numeric. Put the following piece of code in the calculate event of the 'Total' field:

this.rawValue = xfa.resolveNode("form1.page1.NumericField1").rawValue + xfa.resolveNode("form1.page1.NumericField2").rawValue;

Just make the 'Total' field is set as 'Read Only' so that it cant be edited and make sure the script language on the field is set as JavaScript. You must also change the rsolveNodes to match your form. This will sort out your problem.

Avatar

Level 2

Okay, I'm REAL close (I think).  I made the script

this.rawValue = xfa.resolveNode("RoomBoard").rawValue + xfa.resolveNode("TuitionFees").rawValue;

But when I put "100" in one field and "100" in the second field, the "Total" field read "100,100" and not "200"...

Am I almost there??

Avatar

Correct answer by
Level 6

Change the type of all three fields to numeric.  Highlight each field and in the Object window, on the Field tab, pull down the Type dropdown and select "Numeric Field".

Avatar

Level 2

Thank you, thank you!

Sheesh, this stuff is not easy for me... trying to change the color of a field is like rocket science for some reason... I'm sure I'll get the hang of it.

Avatar

Level 2

Sorry, another question.

I did the same with the fields below to add them all together and used the following script (based on binding name updates):

this.rawValue = xfa.resolveNode("ParentsContribution").rawValue
+ xfa.resolveNode("AnticipatedSummerEarnings").rawValue
+ xfa.resolveNode("StudentAssets").rawValue
+ xfa.resolveNode("CollegeFinancialAidOffer").rawValue
+ xfa.resolveNode("OtherScholarship1").rawValue
+ xfa.resolveNode("OtherScholarship2").rawValue
+ xfa.resolveNode("YourJob").rawValue
+ xfa.resolveNode("OhioInstructionalGrant").rawValue
+ xfa.resolveNode("OhioCollegeOpportunityGrant").rawValue
+ xfa.resolveNode("OhioChoiceGrant").rawValue
+ xfa.resolveNode("PellGrant").rawValue
+ xfa.resolveNode("SupplementalEducation").rawValue
+ xfa.resolveNode("AcademicCompetitiveness").rawValue
+ xfa.resolveNode("Loans").rawValue
+ xfa.resolveNode("WorkStudy").rawValue
+ xfa.resolveNode("Gifts").rawValue ;

but I'm not getting a total in the "Total" field.  I've made all fields numeric and the "Total" field read only, too.... thoughts?

Avatar

Former Community Member

Your statement must be on a single line and you do not need an xfa.resolveNode so it should  look like this:

this.rawValue =ParentsContribution.rawValue +  AnticipatedSummerEarnings.rawValue + StudentAssets.rawValue ........

Paul

Avatar

Level 2

Did everything as you said, but the following message comes up

(see attached image)

"Line 2, Column 45" occurs where the first "+" is...

Avatar

Level 6

Am I missing something?  I don't see any attachments to your messages.

Did you set the language to javascript?

Avatar

Level 2

Sorry you didn't get the previos "error message" attachment.  See page 4 on this attachment at the bottom where it says "Total Financial Assistance Available to you".  I changed it to Javascript , so I'm not getting the error message anymore, but the result seems to be "0" and isn't gathering the information just yet....

Avatar

Level 6

I don't have an attachment for any of your posts.  Make sure you're using the Attach Files box and Browsing for your form.

Avatar

Level 2

Hmmm... Did that, but there were error messages, so maybe it didn't go through. I'll try via e-mail instead. Does this work? (sorry for all the trouble, and ignorance)....

Avatar

Level 6

Don't know about email.  You can't post .xdp files, so if that's the extension on your form it won't work. Try renaming it to .xxx and posting.

Avatar

Level 2

it's a .tds file ... I hit "browse" and am attaching it.  Does it work now?

Avatar

Former Community Member

There is still no attachement. Can you save it as a PDF file and attach.