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

New Here ,
Jan 06, 2020

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 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?

Most Valuable Participant
| Most Valuable Participant

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;
event.value = total;``````

TOPICS
Acrobat SDK and JavaScript, Create PDFs, How to, PDF forms

Views

735

Likes

Report

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

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

New Here ,
Jan 06, 2020

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 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?

Most Valuable Participant
| Most Valuable Participant

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;
event.value = total;``````

TOPICS
Acrobat SDK and JavaScript, Create PDFs, How to, PDF forms

Views

736

Likes

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Jan 06, 2020 0
4 Replies 4
Most Valuable Participant ,
Jan 06, 2020

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;
event.value = total;``````

Likes

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Jan 06, 2020 0
New Here ,
Jan 06, 2020

Copied

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

Likes

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Jan 06, 2020 0
Most Valuable Participant ,
Jan 06, 2020

Copied

Sorry, fixed it now.

Likes

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Jan 06, 2020 0
LATEST
New Here ,
Jan 06, 2020