These forums are now Read Only. If you have an Acrobat question, ask questions and get help from one of our experts.

Mixing Javascript and Formcalc on dynamic form

RusticRanger
Registered: Jun 14 2010
Posts: 27
Answered

I have a 28-page form that flows dynamically, and for the most uses Javascript for scripting. Today I had to create a few areas that use a single row table (with header) and a button to dynamically add rows (instanceManager.addInstance) - no problem. But when I looked for a solution for how to total up one column for all dynamically added rows, the only workable solution I found was a FormCalc one

Sum(RowName[*].CellName)

There are a few of these tables, followed by a grand total. The grand total calculation is Javascript - I found that I could use the result of the FormCalc along with the results of other Javascript calculations before that - in the grand total calculation.

The question is: Is there any problem with mixing the results of a FormCalc calculation with the results of a Javascript calculation inside another calculation? The form properties has Javascript as default.

PS. Unfortunately cannot post the form - it is not for public distribution.

Product Version LiveCycle Designer 9.0

My Product Information:
LiveCycle Designer, Windows
thomp
Expert
Registered: Feb 15 2006
Posts: 4411
You can find all the basics for controlling dynamic forms with JavaScript in this eSeminar:
https://admin.adobe.acrobat.com/_a200985228/p87746471/

Each script in LiveCycle is independant. It can JavaScript or it can be FormCalc. Makes absolutely no difference. When you say results I'm assuming you mean form field values? Form fields values and properties can be set and read by any script, it doesn't matter what the language is.

Thom Parker
The source for PDF Scripting Info
[url=http://www.pdfScripting.com]pdfscripting.com[/url]

The Acrobat JavaScript Reference, Use it Early and Often
[url=http://www.adobe.com/devnet/acrobat/javascript.php]http://www.adobe.com/devnet/acrobat/javascript.php[/url]

Then most important JavaScript Development tool in Acrobat
[url=http://www.pdfscripting.com/public/34.cfm#JSIntro][b]The Console Window (Video tutorial)[/b][/url]
[url=http://www.acrobatusers.com/tutorials/2006/javascript_console][b]The Console Window(article)[/b][/url]

Thom Parker
The source for PDF Scripting Info
www.pdfscripting.com
Very Important - How to Debug Your Script

jonom
Registered: Jan 31 2008
Posts: 133
RusticRanger wrote:
But when I looked for a solution for how to total up one column for all dynamically added rows, the only workable solution I found was a FormCalc one Sum(RowName[*].CellName)
Yeah, FormCalc is a lot easier to work with dealing with calculating table data.

For JavaScript you have to write a loop that runs through the fields:
[modified from LiveCycle's help for table example]
var fields = xfa.resolveNodes("Table1.Row1[*].CellName");var total = 0;for (var i=0; i <= fields.length-1; i++){total = total + fields.item(i).rawValue;}this.rawValue = total;
RusticRanger
Registered: Jun 14 2010
Posts: 27
Thanks both - very helpful.
RusticRanger
Registered: Jun 14 2010
Posts: 27
Dear guru's - I hope you can point me in the right direction or help me again - I have posted a new problem with subtraction/division at
http://www.acrobatusers.com/forums/aucbb/viewtopic.php?id=26605