Skip to main content
Participant
Sep 26, 2020 10:37 PM UTC
Question

Need PDF script that will add and multiply text boxes together

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.

This topic is closed to new replies. Start a new post to keep the conversation going.

3 replies

Inspiring
Sep 27, 2020 6:57 AM UTC

The code you posted above doesn't work.

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

Translate
Participant
Sep 28, 2020 2:05 AM UTC

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

Translate
Inspiring
Sep 28, 2020 8:04 AM UTC

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?

Translate