Skip to main content
Participant
February 2, 2024
Answered

Using Radio Buttons to calculate a dollar amount

  • February 2, 2024
  • 1 reply
  • 669 views

Hello, 

 

I'm pretty new to form creation and would like to use radio buttons to calculate a value based on two criteria: resident/non-resident, and early/standard registration period. 

 

The group for the Radio Buttons is "Entry Fee", and the options are 1) "Resident Early Bird", 2) "Non-Resident Early Bird", 3) "Resident Standard", and 4) "Non-Resident Standard". They should output the value that they're associated with in the "Entry Fee Calculation" box. I discovered the custom calculation script feature but can't find the right code to make it work.

 

 

Thanks for the help!

This topic has been closed for replies.
Correct answer Nesa Nurani

You don't need script for this, instead of text give it price value, for example change "Resident Early Bird" to 15...etc for all other buttons, then go to text field properties select 'Calculate' tab and 'Value is the' and pick "Entry Fee".

EDIT:
If you still decide for a script, use this as custom calculation script of text field:

var rb = this.getField("Entry Fee").valueAsString;
var fees = {
 "Resident Early Bird": 15,
 "Non-Resident Early Bird": 18,
 "Resident Standard": 25,
 "Non-Resident Standard": 30};

var total = fees[rb] || 0;
event.value = total;

1 reply

Nesa Nurani
Community Expert
Nesa NuraniCommunity ExpertCorrect answer
Community Expert
February 2, 2024

You don't need script for this, instead of text give it price value, for example change "Resident Early Bird" to 15...etc for all other buttons, then go to text field properties select 'Calculate' tab and 'Value is the' and pick "Entry Fee".

EDIT:
If you still decide for a script, use this as custom calculation script of text field:

var rb = this.getField("Entry Fee").valueAsString;
var fees = {
 "Resident Early Bird": 15,
 "Non-Resident Early Bird": 18,
 "Resident Standard": 25,
 "Non-Resident Standard": 30};

var total = fees[rb] || 0;
event.value = total;
Participant
February 2, 2024

Thank you! Changing the names to their price value worked perfectly, but thank you for the script form as well!