Skip to main content
May 27, 2016
Question

If a checkbox is selected can it perform a calculation?

  • May 27, 2016
  • 1 reply
  • 548 views

I would like to have a check box field and if selected it would return a value in another field. Eg. if selected take the value in field "subtotal" and multiply it by 0.05. return that value in field "GST". Is this possible.

This topic has been closed for replies.

1 reply

try67
Adobe Expert
May 27, 2016

Yes, but it's better to do it from the calculation event of the target field ("GST") then from the check-box itself.

What should be the value of this field if the box is not ticked, though?

May 27, 2016

The value would be $0.00

try67
Adobe Expert
May 27, 2016

OK, then use this code as the custom calculation script (you'll just need to adjust the names of the fields involved to match the actual names in your file):

var subtotal = Number(this.getField("subtotal").value);

event.value = (this.getField("CheckBox1").value=="Off") ? 0 : subtotal * 0.05;