Skip to main content
Participant
Mar 26, 2024 8:48 PM UTC
Question

Calculating totals for fields with and without radio buttons

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 is closed to new replies. Start a new post to keep the conversation going.

1 reply

Nesa Nurani
Community Expert
Community Expert
Mar 27, 2024 5:30 AM UTC

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;
Translate