Copy link to clipboard
Copied
Hello,
I work for a hospital clinic where we reimburse patients for mileage. We have a form in a word doc that I convert it into a PDF, and all I need to do is:
- If patient drove himself, when they check "drove self" I need to take the amount of miles they wrote down and multiply it by 0.625 and then the total will go under the self-drive column.
- If a volunteer drove the patient, when they check "volunteer drove" I need to take the amount of miles they wrote down and multiply it by 0.625 and then the total will go under self-drive column.
One check box is named DroveSelf and the other one is named VolunteerDrove.
The field box under the miles driven is called "MilesDrove"
The field box under the self-drive mileage @ 0.625 is called "SelfDrive"
The field box under Volunteer mileage @ 0.625 is called "VolunteerMileage"
So if a patient stated they self-drove 100 miles. They will need to check the box under "DroveSelf", then that will need to be multiplied by "MilesDrove" at 0.625 and that sum will need to go into "SelfDrive"
Can someone help me with a quick script? Thank you much!
Copy link to clipboard
Copied
The best method is to have calculation scripts in both the "SelfDrive" and "VolunteerMileage" fields.
Here's the Calc script for the SelfDrive field, the other one is nearly the same. The only difference is the checkbox that is used in the "if"
if(this.getField("DroveSelf").value != "Off")
event.value = 0.625 * this.getField("MilesDrove").value;
else
event.value = 0;
However, you do have an issue. It seems that these checkboxes should be mutually exclusive.
You can read how to make the checkboxes mutually exclusive, and how to write "if" statements here:
https://www.pdfscripting.com/public/Checkboxes-and-Radio-Buttons.cfm
https://www.pdfscripting.com/public/How-to-write-an-If-statement.cfm