I have read through the forums and tried to copy several scripts to no avail. Here is the 1st scenario: I want a field to calculate a students Attendance percentage based on the days present and days absent. So the formula on paper is Days Present / (Days present + Days absent). My fields are named DP, DA and Attendance
Here is the 2nd scenario: I also have another field that will display a simple division formula A/ P but I do not want any of these fields to return the message " The value entered does not match the format of the field []" so I know I also need my scripts to indicate that there can be a null value or zero in any of these 6 fields.
All help is greatly appreciated!
*I am using 9.3.3 Pro
DA = this.getField("DA").value;
DP = this.getField("DP").value;
// First we make sure all values are filled in
if (DA==null || DA=="" || DP==null || DP=="") {
event.value = "";
} else {
// Now we make sure the sum of the days present and days absent is not zero, to prevent division by zero
totalDays = DA + DP;
if (totalDays==0) {
event.value = "";
} else {
event.value = DP / (totalDays);
}
}
Custom calculation script for the 2nd scenario:
P = this.getField("P").value;
A = this.getField("A").value
if (A == null || A == "" || P == null || P == "" || P == 0) {
event.value = "";
} else event.value = A/P;
- AcrobatUsers Community Expert - Contact me personally at try6767 [at] gmail [dot] com
Check out my custom-made scripts website: http://try67.blogspot.com