Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
Bedrock Mission!

Learn more

View all

Sign in to view all badges

object references using FormCalc

Avatar

Not applicable
Hello



Does anyone know of the FormCalc equivilant to the following javascript code?



var a = event.target.getField("form[0].page[1].field1");



Basically what I am doing is manipulating the data in field1 form several other fields. The other fields all use FormCalc, to do some calculations.



For example say field2 has the following javascript:



var a = event.target;

var lcv;

var total = 0;



for (lcv = 0; lcv < 10; lcv++)

total = total + a.getField("form[0].page[1].field1["+lcv+"]").value;



I would like to do the samething using FormCalc (I have some other fields that use FormCalc to do stuff, but I need to also do the same kind of sumation) without having to hard code all the fields.



Thanks



Ben



P.S. if you know the synax for a for loop in FormCalc that would be helpful also, but not critical since I can use a while loop.
8 Replies

Avatar

Not applicable
You can't do exactly that in FormCalc. What your doing there is querying Acrobat's Document object (event.target) to get the AcroForm field in the PDF (the result of getField). Acrobat's scripting model is only available in JavaScript, not FormCalc.



If the only thing you want to do is get the value in the field there is no reason to use getField() to get the AcroForm field. Just query the field directly in FormCalc and get the rawValue. IE: fieldName.rawValue.



You can read about the syntax of the for loop in FormCalc on page 23 of the FormCalc reference which is installed in the documentation directory of Designer.



Chris

Adobe Enterprise Developer Support

Avatar

Not applicable
Chris,



I did not think FormCalc supported what I needed but I was hoping I was wrong and therefore hoped to avoid having to query the field directly because the area I am working over basically equates to a 2 dimensional array (but its is not actually one) with a considerable number of fields, I was hoping not to have to hard code the field names for direct access, but if I must, I must, since in need FormCalc functions in part of my validation ( I use parse and format, as well as R&Ltrim) before the calculations.



I check page 23 for the FormCalc reference guide which comes with 7.0 and it talks about how to access elements in a tree, not the syntax of a for loop. If you have a simple example that would suffice.



Thanks



Ben

Avatar

Not applicable
Sorry, it's page 23 in the reference that comes with Designer 7.1. In any case, here's an example:



var List = ref(xfa.record.lists.list1)

for i=0 upto List.nodes.length - 1 step 2 do

$.addItem (List.nodes.item(i).value,"")

endfor



Also take a look at the resolveNode() and resolveNodes() to reference nodes without hard coding full paths for them. There's still no need to to use getField() and work on the AcroForm widgets if all you want is the value, and I strongly recommend against not working on AcroForm widgets unless there is no other way.



Chris

Adobe Enterprise Developer Support

Avatar

Not applicable
HI



Can any one let me know how to read a text file or other pdf file on a local machine using formcalc or javascript on an adobe form?

Avatar

Not applicable
simple simple simple question..... first time user here, I have multiple objects that contain #'s. I'm adding those objects to display in another object called "total". Each time I add a number to the form, the total object remembers the last total and adds all the numbers yet again. How do I code this to simply add the numbers that are displayed (just like excel would do)?

Avatar

Not applicable
Here's a simple sample.. You can see the script on the calculate event of the field NumericField5, which has total as it's caption.



Chris

Adobe Enterprise Developer Support

Avatar

Not applicable
Thanks Chris! I havent been able to get back to the forum shortly after I sent that email, I discovered a typo in one of the field names I was using. The behavior was so unique it appeared intentional!



My mistake, thank-you for responding.



As a side note, Ill never make another form in anything but LiveCycle Designer! Very powerful & easy with a little persistence.

Avatar

Not applicable
On a similar note, I've created a form by importing a Word Document into LiveCycle. I've got all my sum calculation to work and using the sum function have been able to reference the values in non-congruent objects.



Now I'm trying to do that with text fields but can't figure out how. I just want the applicant's name to repeat throughout the form (where required) when it is entered at the top of the first page.



I can not find the FormCalc script for this anywhere. I don't imagine it is very elaborate.



Thank you.