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

Registration

Unfortunately, this username is already taken!

Unfortunately, this e-mail address is already used!

Please retype the verification code.

All fields are required

Retrieving value from a radiogroup

Welcome, Guest
Username Password: Remember me

Retrieving value from a radiogroup
(1 viewing) (1) Guest
  • Page:
  • 1

TOPIC: Retrieving value from a radiogroup

Retrieving value from a radiogroup 1 year, 11 months ago #10041

I have a form with a radiogroup called 'Opcoes' with item such as, for example:

22|Option 1
40|Option 2
350|Option 3

the values before options representing prices

I have a hidden field called 'Total' and a text box called 'Pax' which reflects the number of people to participate in activities defined by the radiogroup options.

What I want is to multiply the 'Pax' field by the value chosen by who is submitting the form, so 22, 40 or 350.

I tried this:
document.getElementById('Total').value = parseFloat((document.getElementById('Pax').value) * (document.getElementById('Opcoes').value))


but it doesn't work. Then I saw a thread derived from the script example named something like 'performing calculations with radio groups' but I can't adpat it to my case, or at least I'm too much a beginner to be able to do it. Can anybody help me, or put me into the right track, please?

May I add that in the submissions the values for the radiogroup and the pax fields are shown:(

Thanks
Last Edit: 1 year, 11 months ago by marioliveira. Reason: adding information

Re:Retrieving value from a radiogroup 1 year, 11 months ago #10068

  • andreic
  • OFFLINE
  • Moderator
  • Posts: 494
You can try using a script similar to this one in the Form Layout tab in order to calculate the Total value of the fields you are trying to multiply:

<script type="text/javascript">
function calculateField()
{
if(document.getElementsByName('form[Opcoes]')[0].checked)
document.getElementById('Total').value=parseFloat(document.getElementById('Pax').value) * parseFloat(document.getElementsByName('form[Opcoes]')[0].value);
 
if(document.getElementsByName('form[Opcoes]')[1].checked)
document.getElementById('Total').value=parseFloat(document.getElementById('Pax').value) * parseFloat(document.getElementsByName('form[Opcoes]')[1].value);
 
if(document.getElementsByName('form[Opcoes]')[2].checked)
document.getElementById('Total').value=parseFloat(document.getElementById('Pax').value) * parseFloat(document.getElementsByName('form[Opcoes]')[2].value);
 
}
</script>


The script verifies which radio button is selected from the field "Opcoes" and multiplies with the value set in the field "Pax" and sets it in the field "Total". Also you will have to add the following code line in the Additional Attributes box of the radio group field:

onclick="calculateField();"
Please note: my help is not official customer support. To receive your support, submit a ticket by clicking here
Regards,
RSJoomla! Development Team

Re:Retrieving value from a radiogroup 6 hours, 1 minute ago #0

Hello,
This is an automatically generated message.
We do not monitor these forums. The forum is provided to exchange information and experience with other users ONLY. Forum responses are not guaranteed.

However, please submit a ticket if you wish to receive our support. Our ticketing system is the only way of getting in touch with RSJoomla! and receiving the official RSJoomla! Customer Support.

For more information, the Support Policy is located here: http://www.rsjoomla.com/support-policy.html.

Thank You!
PLEASE NOTE: This topic is NOT locked and you can add replies to it. Other users are free to reply as well. This message has been generated by a bot and has no effect on the topic whatsoever.
  • Page:
  • 1
Moderators: alex, alexp, octavian, bogdanc, andreic
Time to create page: 0.80 seconds
Feedback