# Basic calculations for checkboxes, and customizing radio buttons (completely new to this)

Contributor ,
Nov 09, 2018 Nov 09, 2018

Copied

So I was completely unaware of javascript and calculations forms within the PDF world, but it would come in handy for a project I'm working on.

This is an order form for printed collateral. I've designed it into categories (per type of print), and 4 columns in each row for quantities, and a checkbox for each quantity.

I've done the pre-work by defining all of my checkbox values and unique names, now the hard part.

I want to have a subtotal calculated from a selection of checkboxes, then each subtotal from each category will be added for a final total value. I've tinkered around in the 'prepare form' calculation property, but it doesn't revert to zero when a checkbox is deselected, and it recalculates all boxes checked every time a new box is checked. Ex: 250 is checked, and it calculates 115, but if an additional box is checked with a value of 145, it calculates it at (115 x 2) + 145 = 375, and it simply adds the value every time a box is checked or unchecked.

Is there way to predefine each Button Value with an if-type statement? If off then 0, on then 115? I'm more of an excel savvy designer (for now).

In regards to the radio button part of my question, is it simple to add a snippet of code that will allow an individual to deselect a radio button? I don't want people to be able to select more than one quantity per row, but if they select it by accident, there's no going back... yet. If not, then I'll just leave it as a checkbox.

Attached is an image of the layout.

TOPICS
Acrobat SDK and JavaScript, Macintosh

Views

275

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

Most Valuable Participant , Nov 09, 2018 Nov 09, 2018
Keep using check-boxes. Give them the same name but different export values to prevent multiple fields in the same group from being selected at once. Clearing the selection in a radio-button group requires a script to reset it, which is not very convenient in most cases.If you set the prices as the export values of the check-boxes then you'll just need to sum them up under your subtotal field, and it will work as you've described. Make sure to only enter numbers, without the dollar symbol.

Likes

2 Replies 2
Most Valuable Participant ,
Nov 09, 2018 Nov 09, 2018

Copied

Keep using check-boxes. Give them the same name but different export values to prevent multiple fields in the same group from being selected at once. Clearing the selection in a radio-button group requires a script to reset it, which is not very convenient in most cases.

If you set the prices as the export values of the check-boxes then you'll just need to sum them up under your subtotal field, and it will work as you've described. Make sure to only enter numbers, without the dollar symbol.

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
Contributor ,
Nov 09, 2018 Nov 09, 2018