KCTechNet
asked on
get checked values with dynamic classes
I have 8 tables, each table having several radio button groups. I am trying to get the sum of the checked values for each table, which I am calling 'sections'. I have 8 input boxes that will be holding the sums for their section. For the radio buttons in section one I have a class of "S1". The radio buttons in section two have a class of S2, and so on. I want to loop 8 times to get the totals of each section but I don't know how to reference the checked by class dynamically.
Here is one of the things I have tried:
Here is one of the things I have tried:
$('#survey').submit(function()
{
var result = 0;
for (var i=1; i<3; i++)
{
result = 0;
$(".S"+i).attr("checked").each(function () {
result += parseFloat($(this).val());
});
$("#sectionTotal"+i').val(result);
}
return false;
});
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
thanks.