Skip to main content
Participant
September 12, 2023
Question

Value from a text box, added to multiple check boxes yield a total

  • September 12, 2023
  • 1 reply
  • 444 views

So I am creating some PDF's for my D&D group, and I'm the type that like automation.

Here is my setup:

Text Box PROF

Text Box STMD
Check box1 STPR

Check box2 STEX

Text Box ACRO

I've tried a few scripts from the site, but I am completly new at this. so I apologize if this has beeb asked.

I want to enter a number in STMD and PROF manually then  if  the check box STEX  is checked  multiply the value of PROF x 2. Then if check box STPR is checked add the value of PROF to STMD then report to ACRO. of course if nothing is checked to just report STMD to ACRO. 
If you play D&D you understand what i'm tryin to do. with the basic formula I can configure the rest of the fields I will need.

 

Thanks

This topic has been closed for replies.

1 reply

Thom Parker
Community Expert
Community Expert
September 12, 2023

Calculation script for ACRO:

 

var nProf = this.getField("PROF").value;
var nStmd = this.getField("STMD").value;

var nOut = nStmd ;
if(this.getField("STEX").value != "Off")
   nProf = nProf * 2;

if(this.getField("STPR").value != "Off")
   nOut = nProf + nStmd ;

event.value = nOut;

 

 

 

Thom Parker - Software Developer at PDFScriptingUse the Acrobat JavaScript Reference early and often