# Calculate radio field values per page

**URL:** <https://community.gravityforms.com/t/calculate-radio-field-values-per-page/10770>\
**Category:** Get Help\
**Tags:** gform\_pre\_submission, calculations, subtotal\
**Created:** [September 21, 2021, 3:18pm UTC](https://community.gravityforms.com/t/calculate-radio-field-values-per-page/10770 "2021-09-21T15:18:28Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![user6149f60133151661](https://avatars.discourse-cdn.com/v4/letter/u/b9bd4f/32.png) [@user6149f60133151661](https://community.gravityforms.com/u/user6149f60133151661)\
**Post date:** [September 21, 2021, 3:18pm UTC](https://community.gravityforms.com/t/calculate-radio-field-values-per-page/10770/1 "2021-09-21T15:18:28Z")

</div>

Hi,

I have a multi-page form with 4 radio fields per page.

Each radio field has 2 options (disagree & agree). Disagree has value 1 and agree has value 2.

I would like to add a hidden field on each page that calculates the total value based on the selection. For example: if a user selects ‘agree’ on each of the 4 fields, the total value of the hidden field should be 4 x 2 = 8.

Is there a way to get this working for each page separately?

Thanks in advance!

---

<div class="post-metadata">

**Author:** ![chrishajer](https://sea2.discourse-cdn.com/flex020/user_avatar/community.gravityforms.com/chrishajer/32/88_2.png) [@chrishajer](https://community.gravityforms.com/u/chrishajer)\
**Post date:** [September 21, 2021, 4:40pm UTC](https://community.gravityforms.com/t/calculate-radio-field-values-per-page/10770/2 "2021-09-21T16:40:15Z")

</div>

Hi Mel. Yes, you can do this. Add a Number field to each page, and enable the calculation. For the calculation, add up all the fields in that page of the form. I like to leave the field visible while testing, and then you can make it hidden visibility on the Advanced tab when you’re convinced it works.

You can do that same thing on all pages of the multi-page form.

If you have any questions about the setup, please let me know.

---

<div class="post-metadata">

**Author:** ![user6149f60133151661](https://avatars.discourse-cdn.com/v4/letter/u/b9bd4f/32.png) [@user6149f60133151661](https://community.gravityforms.com/u/user6149f60133151661)\
**Post date:** [September 21, 2021, 5:02pm UTC](https://community.gravityforms.com/t/calculate-radio-field-values-per-page/10770/3 "2021-09-21T17:02:07Z")

</div>

Hi Chris

Thank you, that is a workable solution. But is it also possible to write some php function to automate the calculation?

---

<div class="post-metadata">

**Author:** ![chrishajer](https://sea2.discourse-cdn.com/flex020/user_avatar/community.gravityforms.com/chrishajer/32/88_2.png) [@chrishajer](https://community.gravityforms.com/u/chrishajer)\
**Post date:** [September 22, 2021, 5:00pm UTC](https://community.gravityforms.com/t/calculate-radio-field-values-per-page/10770/4 "2021-09-22T17:00:11Z")

</div>

Hi Mel. Yes, of course. You could use the gform\_pre\_submission filter to perform your calculation, and populate a field in the form with the result:

> **[gform\_pre\_submission](https://docs.gravityforms.com/gform_pre_submission/)**
>
> This action can be used to modify the posted values after form validation but prior to creating the entry.

---

<div class="post-metadata">

**Author:** ![user6149f60133151661](https://avatars.discourse-cdn.com/v4/letter/u/b9bd4f/32.png) [@user6149f60133151661](https://community.gravityforms.com/u/user6149f60133151661)\
**Post date:** [September 23, 2021, 11:23am UTC](https://community.gravityforms.com/t/calculate-radio-field-values-per-page/10770/5 "2021-09-23T11:23:58Z")

</div>

Thanks!

I’m not sure how to get all selected radio field values per page with php (without manually inserting field ids).

I really appreciate any help in this. My php skills are not that advanced.

---

<div class="post-metadata">

**Author:** ![EliasGomez](https://sea2.discourse-cdn.com/flex020/user_avatar/community.gravityforms.com/eliasgomez/32/2717_2.png) [@EliasGomez](https://community.gravityforms.com/u/EliasGomez)\
**Post date:** [September 29, 2021, 8:19pm UTC](https://community.gravityforms.com/t/calculate-radio-field-values-per-page/10770/6 "2021-09-29T20:19:08Z")

</div>

I’d recommend you to do it with hidden fields. Why do you want to do it with code? 🤔

Anyway, you have 2 functions to get the values:

> **[rgpost()](https://docs.gravityforms.com/rgpost/)**
>
> The rgpost() function in Gravity Forms is used to access an input value from a POST request. This articles explains how to use it.

> **[rgar()](https://docs.gravityforms.com/rgar/)**
>
> This Gravity Forms function returns a value within an array based on providing a reference to an array and a key for that array.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex020/uploads/gravityforms1/original/2X/f/fef63f0599c45e0218c30d9f5d7ca8bff9b00189.png) [@system](https://community.gravityforms.com/u/system)\
**Post date:** [October 29, 2021, 8:19pm UTC](https://community.gravityforms.com/t/calculate-radio-field-values-per-page/10770/7 "2021-10-29T20:19:28Z")

</div>

Closed on October 29, 2021, 8:19pm UTC

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.
