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

calculate variables to get result from a third variable

New Here ,
Jan 29, 2021 Jan 29, 2021

Copy link to clipboard

Copied

I have Acrobat Pro 2020 and finishing with creating a form, but, of course, I am running into a problem 🙂

 

I have 4 variables: Gender, Conclusion1, Conclusion2, and Percentage

Gender results in a 1 for female and 2 for male

Conclusion1 has already been calculated based on female-related percentage scores derived from total items selected as yes

Conclusion2 has already been calculated based on male-related percentage scores derived from total items selected as yes

I am trying to write code for the Percentage variable that will basically say "if gender = 1, then display the results from the variable Conclusion1; and f gender = 2, then display the results from the variable Conclusion2

Ideas on writing this code?

TOPICS
How to

Views

235

Translate

Translate

Report

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 ,
Jan 29, 2021 Jan 29, 2021

Copy link to clipboard

Copied

You can use this code as the custom calculation script of the percentage score field:

var gender = this.getField("Gender").valueAsString;

if (gender=="1" ) event.value = this.getField("Conclusion1").valueAsString;

else if (gender=="2" ) event.value = this.getField("Conclusion2").valueAsString;

else event.value = "";

Votes

Translate

Translate

Report

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 ,
Jan 29, 2021 Jan 29, 2021

Copy link to clipboard

Copied

This works great; however, as I change the number of yes responses, Conclusion1 and Conclusion2 update correctly, but the Percentage field changes to other weird numbers?

Votes

Translate

Translate

Report

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 ,
Jan 29, 2021 Jan 29, 2021

Copy link to clipboard

Copied

Thanks for your help!

 

This works great; however, as I change the number of yes responses, Conclusion1 and Conclusion2 update correctly, but the Percentage field changes to other weird numbers?

Votes

Translate

Translate

Report

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 ,
Jan 29, 2021 Jan 29, 2021

Copy link to clipboard

Copied

As I responded above, this works great; however, as I change the number of yes responses, Conclusion1 and Conclusion2 update correctly, but the Percentage field changes to other weird numbers? When I select a different gender and then go back to the same gender, everything updates correctly. That is also the case if I just selct the other gender. So this Percentage does not update as I add the number of yes responses --- unless I re-enter the Gender?

Votes

Translate

Translate

Report

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 ,
Jan 29, 2021 Jan 29, 2021

Copy link to clipboard

Copied

LATEST

Change the field calculation order. 

Votes

Translate

Translate

Report

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