Skip to main content
Robin_Crawford_Vet_Centre
Participant
September 24, 2021
Question

Creating a simple formula in Acrobat form

  • September 24, 2021
  • 1 reply
  • 392 views

I want to be able to create a simple order form. The client enters in the dose (field: "01Dose") they will administer to an animal, and number of animals (field: "01Animals) being treated. I then want to multiple the two fields together and divide by the volume in a container so I know how many containers they want. It would also be good to ROUNDUP to next full container.

 

Example Excel

=ROUNDUP(("01Dose"*"01Animals")/10000,0)

(In this case the volume of the container is 10,000mls or 10 litres)

(2.0 (Dose Rate ml) x 5876 (Number of Animals))/10000  (Number of Millilitres in a container) = 1.1752 containers ... rounded up to 2 being the number of containers that the client requires.

This topic has been closed for replies.

1 reply

Nesa Nurani
Community Expert
Community Expert
September 24, 2021

Try this as custom calculation script:

var a = Number(this.getField("01Dose").valueAsString);
var b = Number(this.getField("01Animals").valueAsString);
var x = Math.ceil((a*b)/10000);
if(x == 0) event.value = "";
else event.value = x;

Robin_Crawford_Vet_Centre
Participant
September 24, 2021

Hi Nesa, thank you so much for your reply. Not sure what I am doing wrong ...

I added the script but it just won't populate the field, nothing appears. In the case above it is line 13, so changed the fields to this, and the drum is 20 Litres so updated the script to 20000, but the rest is the same

I must be doing something wrong? Any suggestions

 

try67
Community Expert
Community Expert
September 24, 2021

Change the value of one of the fields for the script to "kick in".

If it still doesn't work check the JS Console (Ctrl+J) for error messages.