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

Need PDF script that will add and multiply text boxes together

New Here ,
Sep 26, 2020 Sep 26, 2020

Copy link to clipboard

Copied

I know very little about scripts so please bear with me. First I'll explain what I did and then explain how I need to modify what I did to do something slightly different.

I originally wanted a text box ("ACRO_St") to display the value of a second text box ("Dex_B") automatically, but when a checkbox called "ACRO" was checked, ACRO_St would then display the value of Dex_B plus the value of a third text box called "Prof_B" (and I wanted a plus sign in front of the final value). Knowing zero about scripting but reading the help provided by forum users to others, I was able to accomplish what I wanted with the following script:

 

if (getField("ACRO").value=="Yes")
event.value = getField("Dex_B").value+getField("Prof_B").value;
else event.value = getField("Dex_B").value
if (event.value>0){var cr ="+"}else{var cr=""}AFNumber_Format(0,0,0,0,cr,true)

 

Now I want to modify this script so that, while continuing to do what it already does, if I then check a second checkbox called ("ACRO_Ex"), the text in "ACRO_St" would add the value of Dex_B with twice the value of Prof_B (i.e, Dex_B + (Prof_B x 2)). Any help in doing this from the geniuses in this community would be amazing.

TOPICS
Acrobat SDK and JavaScript

Views

400

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
Enthusiast ,
Sep 26, 2020 Sep 26, 2020

Copy link to clipboard

Copied

The code you posted above doesn't work.

Will at some point both checkboxes  be checked at the same time?

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 ,
Sep 27, 2020 Sep 27, 2020

Copy link to clipboard

Copied

It definitely works. I've used it multiple times. 

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
Enthusiast ,
Sep 28, 2020 Sep 28, 2020

Copy link to clipboard

Copied

LATEST

Where do you use that code?

I asume you use it in ACRO_St field as custom calculation script?

I recreate all your fields and that code doesn't work.

Also I ask again will there be situation when both checkboxes are checked or there will always be only 1 checked?

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