Expand my Community achievements bar.

SOLVED

Javascript Sum

Avatar

Level 1

Hi,

I need to have a field in a form that sums the data entered by the user in 5 other fields, and one defined field.  It's super easy to do in Acrobat 9.0, but I need to create the form in LiveCycle and the JavaScript wont transfer from Acrobat to Livecycle.  Here is what I have and it isn't working:

AFSimple_Calculate("SUM", new Array ("LineCalc1", "LineCalc2", "LineCalc3", "LineCalc4", "LineCalc5", "StudentLoan"));

A separate field needs to subtract the value from that calculation from 30,400:

event.value = ( 30400 -
    this.getField("Total_Proposed_Payment_Toward_Tuition_Room_and_Board").value )

I am a complete beginner at JavaScript.  I have tried to figure this out, but I really just don't know where to go! Please help! Thank you.

1 Accepted Solution

Avatar

Correct answer by
Former Community Member

FormCalc uses a simple Excel-like syntax for mathematical operations. Something like this is possible...

// form1.page1.subform1.Total::calculate - (FormCalc, client)

$.rawValue = 30400 - (LineCalc1 + LineCalc2 + LineCalc3 + LineCalc4 + LineCalc5 - StudentLoan)

Steve

View solution in original post

3 Replies

Avatar

Level 7

You are using Acrobat Form Tool code, so unless you are making your form with Acrobat, I would use the syntax and languages of LiveCycle Designer.

Look in the scripting reference for the 'Sum' function and examples of how to write equations in LiveCycle Designer. The 'Scripting Reference' is under LiveCycle Designer's "Help" menu option.

Avatar

Correct answer by
Former Community Member

FormCalc uses a simple Excel-like syntax for mathematical operations. Something like this is possible...

// form1.page1.subform1.Total::calculate - (FormCalc, client)

$.rawValue = 30400 - (LineCalc1 + LineCalc2 + LineCalc3 + LineCalc4 + LineCalc5 - StudentLoan)

Steve

The following has evaluated to null or missing: ==> liqladmin("SELECT id, value FROM metrics WHERE id = 'net_accepted_solutions' and user.id = '${acceptedAnswer.author.id}'").data.items [in template "analytics-container" at line 83, column 41] ---- Tip: It's the step after the last dot that caused this error, not those before it. ---- Tip: If the failing expression is known to be legally refer to something that's sometimes null or missing, either specify a default value like myOptionalVar!myDefault, or use <#if myOptionalVar??>when-present<#else>when-missing. (These only cover the last step of the expression; to cover the whole expression, use parenthesis: (myOptionalVar.foo)!myDefault, (myOptionalVar.foo)?? ---- ---- FTL stack trace ("~" means nesting-related): - Failed at: #assign answerAuthorNetSolutions = li... [in template "analytics-container" at line 83, column 5] ----