Skip to main content
joshua26458132htkn
New Participant
October 6, 2022
Answered

Adobe Acrobat JavaScript Customer calculation with radio buttons to display text

  • October 6, 2022
  • 1 reply
  • 1444 views

Hey Everyone,

 

I have built a interactive form that has 10 fields (Advancement Drive, Drive to Excel, Development Commitment, People Agility, Mental Agility, Change Agility, Self Awareness, Performance, Company9, Leadersihp) and 30 radio buttons total.  Each of the 10 fields is given 3 radio buttons, valued (1,2 or 3) and totaled at the bottom in a "Score" field in the calculation and then displays text in the "Potential Rating" field.  It will show either (Grow With Role, Promotable, or High Potential).  What I am struggling with is if (Advancement Drive, Drive to Excel, Development Commitment) are individually selected with the value of 1 then the potential rating text needs to display "Grow With Role" no matter what the total calculation sum ends up totaling.  If they don't have any of those 3 fields at value 1 then it should calculate the total sum as normal.  Is this possible to do?

 

var sum = this.getField("Score").value;
if (sum <= 17){
event.value = "Grow With Role";}
else if((sum <= 22) && (sum >=17)){
event.value = "Promotable";}
else if(sum >= 23){
event.value = "High Potential";}
 
Thanks,
 
Joshua
This topic has been closed for replies.
Correct answer Nesa Nurani

Can you share file or let us know names of radio buttons?

EDIT:

var ad = this.getField("Advancement Drive").valueAsString;
var de = this.getField("Drive to Excel").valueAsString;
var dc = this.getField("Development Commitment").valueAsString;

var sum = Number(this.getField("Score").valueAsString);
if(sum){

if(ad=="AD1"&&de=="DE1"&&dc=="DC1")
event.value = "Grow With Role";
else if(sum <= 17)
event.value = "Grow With Role";
else if((sum <= 22) && (sum >=17))
event.value = "Promotable";
else if(sum >= 23)
event.value = "High Potential";}
else
event.value = "";

 

1 reply

Nesa Nurani
Nesa NuraniCorrect answer
Community Expert
October 6, 2022

Can you share file or let us know names of radio buttons?

EDIT:

var ad = this.getField("Advancement Drive").valueAsString;
var de = this.getField("Drive to Excel").valueAsString;
var dc = this.getField("Development Commitment").valueAsString;

var sum = Number(this.getField("Score").valueAsString);
if(sum){

if(ad=="AD1"&&de=="DE1"&&dc=="DC1")
event.value = "Grow With Role";
else if(sum <= 17)
event.value = "Grow With Role";
else if((sum <= 22) && (sum >=17))
event.value = "Promotable";
else if(sum >= 23)
event.value = "High Potential";}
else
event.value = "";

 

joshua26458132htkn
New Participant
October 6, 2022

here is the file and the 3 groups that need to overide the sume if selected are below.

 

 

Nesa Nurani
Community Expert
October 6, 2022

Check my post above I changed script, try and see if it works for you.