can you do a calculation based on the option selected in a radio button field?

By: Larry Kolinek | Asked: 11/21/2022
ForumsCategory: General questionscan you do a calculation based on the option selected in a radio button field?
Larry Kolinek asked 2 years ago
Hi, so, lets said: radio button has 3 options: red = 10 blue = 15 white = 20   I have a total field and want to calculate (or set) another field to the value associated with the radio button selections. So if blue is selected, set Total to 15.   can that be done?
2 Answers
Best Answer
Larry Kolinek answered 2 years ago
little different idea:   i need the total field to calculate: a) the radio button option selected, its value (this works) b) I have a checkbox and IF checked, how to increase the total value of the "total field" ? where total field = radio button option + checkbox value   can a checkbox have a value?
Larry Kolinek replied 2 years ago

NEVER MIND... i got it working.

SO any field that can take a value (text or number, etc)... you can always use that in the calculation 🙂

Bobby Clapp replied 2 years ago

Yes. One thing to note (as you have determined) is that if you have the same value in the "use separate values" it will not work. You can use a combination of text and a numerical value to make it unique and it will trim out the value and use the numeric portion.

Bobby Clapp answered 2 years ago
Save the field options as "use separate values" and an additional field will pop up where you can add those numerical values. Then your calculation would base off that.
Larry Kolinek replied 2 years ago

thanks... i see you can add text as well, but only numbers will be used.

So adding to my calculations, the complete goal I have:
1) get the value from the radio button field (which can be done)
2) i have a date field, IF a date is entered, then I need to ADD to the TOTAL field a set amount.

where this happens:
a) pick radio button option
b) optional to select a date
c) total field (radio button + optional date field amount = total)

any thoughts how to accomplish that?

thanks!

Rob LeVineRob LeVine replied 2 years ago

Hey Larry, long time no see. Your goal is easy to accomplish in jQuery. Are you averse to that as a solution?

Making the Best WordPress Plugin even better - Together

Take on bigger projects with confidence knowing you have access to an entire community of Formidable Experts and Professionals who have your back when the going gets tough. You got this!
Join the community
crossarrow-right