Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Adobe Acrobat JavaScript Customer calculation with radio buttons to display text

New Here ,
Oct 06, 2022 Oct 06, 2022

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
TOPICS
General troubleshooting , How to , JavaScript
1.2K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
1 ACCEPTED SOLUTION
Community Expert ,
Oct 06, 2022 Oct 06, 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 = "";

 

View solution in original post

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Oct 06, 2022 Oct 06, 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 = "";

 

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Oct 06, 2022 Oct 06, 2022

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

 

joshua26458132htkn_0-1665075238794.pngexpand image

 

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Oct 06, 2022 Oct 06, 2022

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

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Oct 06, 2022 Oct 06, 2022
LATEST

Thank you!  I made a small change ( or v. and) and it seem working great!

 

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 = "";

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines