Skip to main content
Participating Frequently
Feb 4, 2025 4:58 AM UTC
Answered

Simple form requiring simple Javascript, tearing hair out

I have a form with radio buttons and a total.

 

When you select certain buttons the price is totalled in a 'Total' field box..

 

There is one radio button 'Withdrawal' that if clicked, the total price in the 'total' field needs to increase by 6.9% 

I've tried adding code to 'Total' the extra 6.9% if the radio button 'Withdrawal' is selected. No Luck

I've tried adding code to ''Withdrawal' radion button to incrase the 'Total' by 6.9% if selected. No Luck

 

PDF ATTACHED!

Nesa Nurani
Nesa NuraniCorrect answer
Community Expert
Feb 4, 2025 5:23 AM UTC

Use this as custom calculation script in "Total" field, it will calculate all checkboxes and add 6.9% increase if withdrawal is checked:

var fields = [
  "MarketingPackageA",
  "MarketingPackageB",
  "MarketingPackageC",
  "Audience Maximiser",
  "Photo For Sale Sign",
  "Sunset Photoshoot",
  "Be Seen Social Media",
  "Auctioneer’s Fee",
  "Body Corporate Disclosure Statement",
  "Title Search"
];

var per = 1.069;
var total = 0;

for(var i=0; i<fields.length; i++){
 var f = this.getField(fields[i]).valueAsString;
 if(f !== "Off")
  total += Number(f);}

if(this.getField("Withdrawal").valueAsString !== "Off")
total = total*per;

event.value = total.toFixed(2);

2 replies

Nesa Nurani
Community Expert
Nesa NuraniCommunity ExpertCorrect answer
Community Expert
Feb 4, 2025 5:23 AM UTC

Use this as custom calculation script in "Total" field, it will calculate all checkboxes and add 6.9% increase if withdrawal is checked:

var fields = [
  "MarketingPackageA",
  "MarketingPackageB",
  "MarketingPackageC",
  "Audience Maximiser",
  "Photo For Sale Sign",
  "Sunset Photoshoot",
  "Be Seen Social Media",
  "Auctioneer’s Fee",
  "Body Corporate Disclosure Statement",
  "Title Search"
];

var per = 1.069;
var total = 0;

for(var i=0; i<fields.length; i++){
 var f = this.getField(fields[i]).valueAsString;
 if(f !== "Off")
  total += Number(f);}

if(this.getField("Withdrawal").valueAsString !== "Off")
total = total*per;

event.value = total.toFixed(2);
Translate
Participating Frequently
Feb 4, 2025 5:32 AM UTC

OMG It worked! You are amazing! Thank you so much.

Translate