Skip to main content
Participant
Oct 19, 2023 6:56 PM UTC
Question

Calculate Percentage Based on Radio Button Selected

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

4 replies

Nesa Nurani
Community Expert
Community Expert
Oct 20, 2023 12:19 PM UTC

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

 

Translate
Participant
Nov 15, 2023 9:17 PM UTC

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.

 

Translate
Bernd Alheit
Community Expert
Community Expert
Nov 15, 2023 9:29 PM UTC

There you use the value 1.5%

Translate