I have a Number field that I would like to display the total value of a dollar amount when a radio button is selected.
In the example below, in each row where 'Y' is checked, we would like Forms to take the value under the Total Cost column for that row and display the total in the Confirmed Purchase field above the table.
So, 1,994.79+1,421.37 should be 'grabbed' and then 3,416.16 should display in the Confirmed Purchase field.
I tried adapting another posted solution that used check boxes, but that didn't work.
I used a sample from Laserfiche and it is giving me the total of every row. I am trying to see if I can have Forms only include the rows that have a radio button 'Y' checked.
Here is the code I currently have:
$(document).ready(function () {
$('.cf-table-block').on('blur', 'input', sumtotal);
if ($('.subtotal').length > 0) {
$('.cf-table-block').on('blur', 'input', rowtotal);
}
function sumtotal() {
var sum = 0;
$('td.sum').each(function () {
var s = 0;
$(this).find('input').each(function () {
s += parseNumber($(this).val());
});
$(this).find('.subtotal input').val(s);
sum += s;
});
$('.total input').val(sum);
}
function rowtotal() {
var sum = 0;
$('.cf-table-block tbody tr').each(function () {
var s = 0;
$(this).find('.sum input').each(function () {
s += parseNumber($(this).val());
})
$(this).find('.subtotal input').val(s);
sum += s;
});
}
function parseNumber(n) {
var f = parseFloat(n); //Convert to float number.
return isNaN(f) ? 0 : f; //treat invalid input as 0;
}
});