Hi Gang,
I’ve been searching everywhere for some help on this, and I know it doesn’t help that I’m a total newb to js,.. but please bare with me.. any help you provide is greatly appreciated!
Here is what I have:
An HTML Form with a radio buttons and checkboxes,.. about 17 radio buttons [U]groups
right now I have two js snippets to make each of two calcs run. I would like to condense them into snippet.
[U]I only need to calculate two values though.. one value is just the value from a single group of radio buttons : radio50, a group of 3 buttons
Not all the values in the form.. ?
[B]Here is the code I have for this first calc:
[code]
function setupvalue()
{
for (i=0;i<document.form_order.radio50.length;i++)
{
if (document.form_order.radio50[i].checked)
{
radio50_value = “$” + document.form_order.radio50[i].value;
}
}
document.form_order.radio50txt.value=radio50_value;
}
The next value I need to calc is the value for a group of 2 radio buttons: radio51 and radio52 and the 5 checkboxes below them.
The problem I run into is that the script I have for the second calc totals the value for ALL the fields.. so, all the radio buttons/checkboxes are totaled..
[B]Here is the code I have for the second calc:
[code]
function calculateTotal(from_order){
var total = 0;
var elems = from_order.getElementsByTagName(‘input’);
for(var i = 0; i < elems.length; i++){
if((elems[i].type == “radio” || elems[i].type == “checkbox”) && elems[i].checked){
total += parseFloat(elems[i].value);
}
}
total = total.toFixed(2)
from_order.total.value = “$” + total;
}
Keep in mind that this is all in one form..
Here is a visual of what I’m trying to accomplish:
[code]
<form>
* bunch of radio buttons
* some text fields
* some check boxes
—
* radio button group: radio50 – I need the sole value from this group to display in a field at the bottom of the form
—
* radio button group: radio51 – I need the value for this line and the lines below to calc in a separate field at the bottom of the form.
* radio button group: radio 52
* 5 more checkboxes
—
* text field: value of radio50
—
* text field: value of radio51+radio52+5 checkboxes if checked.
</form>
Any help is greatly appreciated! Thank you.. I have been learning a lot just browsing this forum,.. I’m hoping that will continue as I get ‘into’ the forum and start being an active member.
J