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

Checkbox Calculations

Welcome, Guest
Username Password: Remember me

Checkbox Calculations
(1 viewing) (1) Guest
  • Page:
  • 1

TOPIC: Checkbox Calculations

Checkbox Calculations 1 year, 9 months ago #11198

Hi Forum,

The example code below works really well to total up the values of selected radio buttons but does anyone know how to achieve the same thing with checkboxes?

Essentially I have a few radio buttons that calculate the cost of a product but I need a checkbox at the end that can add an optional postage supplement.

Many Thanks,
Chris

function calculate() {
 
var val0=document.getElementsByName('form[style]');
var val1=document.getElementsByName('form[boardA]');
var result=document.getElementById('total');
 
result.value=0;
 
for(i=0;i<val0.length;i++)
if(val0[i].checked) result.value=parseFloat(result.value)+parseFloat(val0[i].value);
 
for(i=0;i<val1.length;i++)
if(val1[i].checked) result.value=parseFloat(result.value)+parseFloat(val1[i].value);
 
result.value=(parseFloat(result.value)).toFixed(2);
 
}

Re:Checkbox Calculations 1 year, 9 months ago #11207

Any thoughts on this? Even a simple, "no, this can't be done" would be great so I can look at other solutions.

Thanks all,

Re:Checkbox Calculations 1 year, 9 months ago #11209

Solved.

The syntax I was try to identify the checkbox with was...

var val10=document.getElementsById('express');


or

var val10=document.getElementsByName('form[express]');


but this is the one that worked...

var val10=document.getElementsByName('form[express][]');

Re:Checkbox Calculations 5 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
Time to create page: 1.29 seconds
Feedback