Skip to main content
Participant
March 26, 2024
Question

Calculating totals for fields with and without radio buttons

  • March 26, 2024
  • 1 reply
  • 334 views

I have created a payment authorization form but am having trouble calculating totals. I attached a copy of the document for reference. Basically I have a box to enter amount then radio buttons to indicate service fees. One is ach and one is credit card fee. Lastly I have a total box. For the ach radio button I would like it to fill in $4 when selected. For the credit card fee I would like it to calculate 3.5% of what is in the amount box. Then I would like the total to add the amount. And which ever value fills in from the radio buttons. How do I accomplish this??

This topic has been closed for replies.

1 reply

Nesa Nurani
Community Expert
Community Expert
March 27, 2024

As 'Custom calculation script' of "Total" field use this:

var rb = this.getField("Group1").valueAsString;
var amt = Number(this.getField("Amount2").valueAsString);
var ach = this.getField("ACH Fee");
var cc = this.getField("Credit Card Fee");
var achT = rb === "ACH" ? 4 : 0;
var ccT = rb === "Credit Card" ? (.035*amt) : 0;

ach.value = achT;
cc.value = ccT;
event.value = amt+achT+ccT;