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

Calculating field total based on sum of checkboxes multiplied by a radio button value

New Here ,
Jan 06, 2020 Jan 06, 2020

Copy link to clipboard

Copied

I have a transcript request form that I need to calculate a total dollar amount in a field at the bottom based on which options are selected. The form is set up like this:

 

Checkbox 1:  $5 mail unofficial transcript

Checkbox 2:  $5 mail official transcript

Checkbox 3:  $5 email transcript

 

Radio 1:  BSB transcript 

Radio 2:  degree transcript 

Radio 3:  both BSB and degree transcript ($5 each)

 

Text field total:  This amount should be the sum of the checkboxes (one or more can be selected, each valued at $5) and IF Radio 3 is selected, should be multiplied by 2 (so, if I want a transcript by mail and by email, for both BSB and degree, then my total would be $20; 5+5x2).

 

Is this possible?

TOPICS
Acrobat SDK and JavaScript

Views

1.7K

Likes

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

correct answers 1 Correct answer

Community Expert , Jan 06, 2020 Jan 06, 2020

Yes, it's possible. However, the radio-buttons should have the same name but unique "radio button choice" values, not unique names for each one (because that would mean that you could select multiple ones). Let's say they are all called "Radio" and their values are 1, 2 and 3. You can then use this code as the custom calculation script of your total field:

 

 

var total = 0;
if ((this.getField("Checkbox 1").valueAsString)!="Off") total+=5;
if ((this.getField("Checkbox 2").valueAsString)!="Off") 
...

Likes

Translate

Translate
Community Expert ,
Jan 06, 2020 Jan 06, 2020

Copy link to clipboard

Copied

Yes, it's possible. However, the radio-buttons should have the same name but unique "radio button choice" values, not unique names for each one (because that would mean that you could select multiple ones). Let's say they are all called "Radio" and their values are 1, 2 and 3. You can then use this code as the custom calculation script of your total field:

 

 

var total = 0;
if ((this.getField("Checkbox 1").valueAsString)!="Off") total+=5;
if ((this.getField("Checkbox 2").valueAsString)!="Off") total+=5;
if ((this.getField("Checkbox 3").valueAsString)!="Off") total+=5;
if ((this.getField("Radio").valueAsString)=="3") total*=2;
event.value = total;

 

Likes

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 06, 2020 Jan 06, 2020

Copy link to clipboard

Copied

I'm trying it, but it says there is a "syntax error 2: at line 3."

Likes

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 06, 2020 Jan 06, 2020

Copy link to clipboard

Copied

Sorry, fixed it now.

Likes

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 06, 2020 Jan 06, 2020

Copy link to clipboard

Copied

LATEST

It works, thank you so much!

Likes

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