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

Make java script to do field additions in Acrobat 9

dwc
Registered: Jul 3 2008
Posts: 3

I have a calendar in acrobat 9. i have made a form with separate fields for each day. In each day I can put a V for vacation. W for work . H for holiday. S for sick. I want a field in the form to automatically add all the V's and put the numerical number in a new field box. There will be separate boxes collecting each.

What java script can I put there to collect the data?

My Product Information:
Acrobat Standard 8.1.2, Macintosh
gkaiseril
Online
Expert
Registered: Feb 23 2006
Posts: 4308
Not enough detailed information.

For AcroForms the "Custom calculation script" or the "The ___ of:" itshould work just the same way it has since version 4. And the "Simplified Field Notation" should work as it has since being introduced in version 6.

If you are using LiveCycle Designer, it should work just like it has since version 6.

There are on demand videos for both of these products on the AUC home page.

George Kaiser

dwc
Registered: Jul 3 2008
Posts: 3
There are 30 fields labeled text1 through text30. In each field I can type in H or W or V or D. I would like to have a total W field that calculates the number of times W appears in all the fields. And a total V field that calculates the number of times V appears in all the fields. and so on.

Is there a script for that calculation?
George_Johnson
Expert
Registered: Jul 6 2008
Posts: 1876
Try something like the following as the custom calculation script of the field that displays the total vacation days:

// Initialize counter
var sum = 0;

// Loop through fields and count the number of "V"s
for (var i = 1; i < 31; i++) {
if (getField("text" + i).value == "V") sum++;
}

// Set this field's value equal to the sum
event.value = sum;

You might want to add code to the input fields so that only those certain characters can be entered (or use a combo box, which is probably better for this), and add an extra day for the 31st.


George