Skip to main content
Participant
October 19, 2023
Question

Calculate Percentage Based on Radio Button Selected

  • October 19, 2023
  • 1 reply
  • 576 views

Hello Good People! 🙂
Forwarning you that I have no experience with scripts....

I'm trying to figure out how to calculate the total rate per person based on the radio button (i.e. Method of Compensation) selected.

Scenario:  Based on what type of premium work performed (overtime, holiday, comp time) will determine the percentage of their hourly rate in which they will be paid.  Not sure if it would be easier to deal with decimals.

- Overtime 1.5 or 150%

- Holiday 2.0 or 200%

- Comp Time 0 or 0%

 

Sample portion of form is below:

Thanks in advance!

 

This topic has been closed for replies.

1 reply

Nesa Nurani
Community Expert
Community Expert
October 20, 2023

Let's say your radio buttons are named "Group1" with export values of 1.5, 2, and 0.

If you already use a custom calculation script in your 'Total' field, add this after your script:

var rb = this.getField("Group1");
if(rb.valueAsString == "1.5" || rb.valueAsString == "2")
event.value = Number(event.value)*Number(rb.valueAsString);

 

Participant
November 15, 2023

Sorry for the late response.  I had a chance to go back and I don't know if it's my version of Adobe but I'm not seeing an option to add a value to a radio button.  Would it be easier to create a drop down with values?  This is the only option I have when I go into properties.

 

Bernd Alheit
Community Expert
Community Expert
November 15, 2023

There you use the value 1.5%