Skip to main content
Known Participant
April 16, 2021
Répondu

Calculating the values of fields and displaying the result totals

I have a form that our employees use to conduct performance evaluations on our various sites. One example would be "site cleanliness," and the options for evaluation in the field would be "compliant", "non-compliant", "repeat non-compliant", "N/A." How would I go about adding up these responses and outputting the total to a field at the bottom. Does this require javascript? I am using Adobe Acrobat Pro DC

Ce sujet a été fermé aux réponses.
Meilleure réponse par Nesa Nurani

Do you have an idea of how I would calculate the scoring criteria as follows? 

Initial Periodic Score (1-5)
Scoring Criteria
5.0 = No deficiencies4.0 = No A deficiencies, less than 30% B deficiencies, less than 50% C deficiencies3.0 = Less than 3 A deficiencies, less than 50% B deficiencies, greater than 50% C deficiencies2.0 = Less than 7 A deficiencies, greater than 50% B deficiencies1.0 = More than 8 A deficiencies


Like I said it would be better to see  file with all fields, you can try something like this if you use percentage from 75 fields.

var x = Number(this.getField("Total").value);
var xda = Number(this.getField("DeficienciesA").value);
var xdb = Number(this.getField("DeficienciesB").value);
var xdc = Number(this.getField("DeficienciesC").value);
if(x == 0)
event.value = "";
else if(xda == 0)
event.value = 5.0;
else if(xda == 0 && xdb < 22.5 && xdc < 37.5)
event.value = 4.0;
else if(xda < 3 && xdb < 37.5 && xdc > 37.5)
event.value = 3.0;
else if(xda < 7 && xdb > 37.5)
event.value = 2.0;
else if(xda > 😎
event.value = 1.0;
else event.value = "";

1 commentaire

Inspiring
April 16, 2021

Yes, you need javascript.

Can you describe how you imagine process, one field to show total, total of what choice?

Or separate fields, one for each choice?

Field names? how many fields?

PhilaGuyAuteur
Known Participant
April 16, 2021

 People will be selecting choices like "deficient", "compliant", "repeat deficient", "N/A" in the analysis column and I want to add those values up to display in the scoring table at the bottom. Each row also has a value of "A", "B", or "C" assigned to it to show the level of importance of each analysis and I also want to calculate the number of choices sorted by the A B, and C importance.  Each of the analysis columns that I want to record scores from are labeled with this convention: "AnalysisA1"(first analysis cell that's valued with "A" importance), "AnalysisA2"(second analysis cell valued at "A" importance), "AnalysisB1" etc.

The most complicated portion for me will be the "Initial Periodic Evaluation Score" Calculation:   

5.0 = No deficiencies
4.0 = No A deficiencies, less than 30% B deficiencies, less than 50% C deficiencies
3.0 = Less than 3 A deficiencies, less than 50% B deficiencies, greater than 50% C deficiencies
2.0 = Less than 7 A deficiencies, greater than 50% B deficiencies
1.0 = More than 8 A deficiencies

PhilaGuyAuteur
Known Participant
April 19, 2021

It would be better if you shared whole file.

From what i can see there should be 16-A, 31-B and 28-C fields and lets say fields for result would be called "DeficienciesA","DeficienciesB","DeficienciesC" use this code in 'total' field:

var DA = 0;
var DB = 0;
var DC = 0;
var total = 0;
for ( var i=1; i<=16; i++){
if(this.getField("AnalysisA"+i).valueAsString == "Deficient")DA++;}
for ( var i=1; i<=31; i++){
if(this.getField("AnalysisB"+i).valueAsString == "Deficient")DB++;}
for ( var i=1; i<=28; i++){
if(this.getField("AnalysisC"+i).valueAsString == "Deficient")DC++;}

total = DA+DB+DC;
if(total == 0){
this.getField("DeficienciesA").value = "";
this.getField("DeficienciesB").value = "";
this.getField("DeficienciesC").value = "";
event.value = "";}
else {
this.getField("DeficienciesA").value = DA;
this.getField("DeficienciesB").value = DB;
this.getField("DeficienciesC").value = DC;
event.value = total;}

This will calculate totals of "Deficient" for each field and total of them.


Do you have an idea of how I would calculate the scoring criteria as follows? 

Initial Periodic Score (1-5)
Scoring Criteria
5.0 = No deficiencies4.0 = No A deficiencies, less than 30% B deficiencies, less than 50% C deficiencies3.0 = Less than 3 A deficiencies, less than 50% B deficiencies, greater than 50% C deficiencies2.0 = Less than 7 A deficiencies, greater than 50% B deficiencies1.0 = More than 8 A deficiencies