Unfortunately, the username and password you have entered do not match!


Unfortunately, this username is already taken!

Unfortunately, this e-mail address is already used!

Please retype the verification code.

All fields are required

RSForm!Pro - How to perform radio group calculations

How to perform radio group calculations

In this article we will describe how to make a simple calculation with values from a radio group. Let suppose, for example, that we have the following components:

1. Radio group:

Name: radio1

Caption: radio1

Items: 1|Description1



2. Radio group:

Name: radio2

Caption: radio2

Items: 1|Description1



3. Hidden field

Name: result

Default Value: 0

4. Submit Button:

Name: submit

Label: submit

Additional Attributes: onclick="calculate();"

Head to Components >> RSForm!Pro >> Manage Forms >> edit your form >> Properties and add the following code in the Javascript area of the CSS and Javascript tab:

<script type="text/javascript">
function calculate()
var op1=document.getElementsByName('form[radio1]');
var op2=document.getElementsByName('form[radio2]');
var result=document.getElementById('result');
  if(op1[i].checked) result.value=parseInt(result.value)+parseInt(op1[i].value);
  if(op2[i].checked) result.value=parseInt(result.value)+parseInt(op2[i].value);
return false;

In order to display the result of this calculation just the placeholder for the hidden field, in this case: {result:value}. This can be used in "Thank You Message" page as well as in any email configuration.

You can read more about the CSS and Javascript tab here.