<p>Two potential ways to address this:</p>

<ol>
<li><p>Setup a Sprout Fields <a href="https://sprout.barrelstrengthdesign.com/craft-plugins/fields/docs/overview/hidden-field" rel="nofollow noreferrer">Hidden Field</a> and add javascript to your page (or in your form template using Template Overrides) to calculate the values and submit the calculated value with the rest of the form.</p></li>
<li><p>Create a <a href="https://sprout.barrelstrengthdesign.com/craft-plugins/forms/docs/customization/custom-front-end-fields" rel="nofollow noreferrer">custom front-end field</a> integration that is aware of the Radio Button fields that you need to process and have that field calculate and display the result of those values. </p></li>
</ol>

<p>The first approach is probably the easiest approach and should work fine if you're sending your submissions via email and if it's unlikely that anybody will be editing the Radio Button fields in the CP.  The second approach may be more robust if there is a chance the Radio Buttons ever get edited and the Total Field needs to get recalculated.</p>

<p><em>Side Note: The Invisible Field won't work in this use case right now as you want to calculate values based on the submitted form values. The Invisible Field lets you pass it dynamic values as the page loads but at that time the page would not have any info on the values of the Radio Buttons.</em></p>

CC BY-SA 3.0
2018-01-04T15:55:49.113Z
Thanks for clarifying the invisible field functionality. The first option worked well for the use case of this form.
raptureaid
CC BY-SA 3.0
2018-01-04T02:01:09.863Z
2018-01-04T02:01:09.863Z
Ben Parizek
<p>I have a form built with Sprout forms that has a few radio button fields, all with numeric values. I'm looking to provide the total sum of these fields to a hidden/invisible field upon submit.</p>

<p>Is it possible to provide the value of the radio button field directly to the Invisible Field Value using twig syntax? Or should I just go the scripting route and use jQuery to update the hidden/invisible field's value?</p>

CC BY-SA 3.0
2018-01-03T14:42:57.320Z
You'll need javascript since twig is only php thus it can't be executed during runtime. So you could only use a custom plugin to hook into the submit process to inject the field value  or you could use Javascript (or some really really nasty twig redirects which nobody wants)
Robin Schambach
<plugin-sproutforms>
Pass radio button values to invisible field in Sprout forms
# Pass radio button values to invisible field in Sprout forms

(Asked by: username_0 on 2018-01-03)

I have a form built with Sprout forms that has a few radio button fields, all with numeric values. I'm looking to provide the total sum of these fields to a hidden/invisible field upon submit.

Is it possible to provide the value of the radio button field directly to the Invisible Field Value using twig syntax? Or should I just go the scripting route and use jQuery to update the hidden/invisible field's value?

**Tags:** plugin-sproutforms
> **Comments:**
> **username_1**: You'll need javascript since twig is only php thus it can't be executed during runtime. So you could only use a custom plugin to hook into the submit process to inject the field value  or you could use Javascript (or some really really nasty twig redirects which nobody wants)  

---

## 1 answers

### Answer by username_2 on 2018-01-04. Score: 0 | Accepted answer

Two potential ways to address this:

1. Setup a Sprout Fields [Hidden Field](https://sprout.barrelstrengthdesign.com/craft-plugins/fields/docs/overview/hidden-field) and add javascript to your page (or in your form template using Template Overrides) to calculate the values and submit the calculated value with the rest of the form.
2. Create a [custom front-end field](https://sprout.barrelstrengthdesign.com/craft-plugins/forms/docs/customization/custom-front-end-fields) integration that is aware of the Radio Button fields that you need to process and have that field calculate and display the result of those values.

The first approach is probably the easiest approach and should work fine if you're sending your submissions via email and if it's unlikely that anybody will be editing the Radio Button fields in the CP. The second approach may be more robust if there is a chance the Radio Buttons ever get edited and the Total Field needs to get recalculated.

*Side Note: The Invisible Field won't work in this use case right now as you want to calculate values based on the submitted form values. The Invisible Field lets you pass it dynamic values as the page loads but at that time the page would not have any info on the values of the Radio Buttons.*

> **Comments:**
> **username_0**: Thanks for clarifying the invisible field functionality. The first option worked well for the use case of this form.  

---

