So what I am trying to do is take the value out of a table currency field and depending on a radio button or check box selection add it to a general fund or federal fund currency field on a separate table. While doing this take the value of a (not dynamically populated) drop down and put it into a text field to have a query run against it.
Any Help with the direction I am trying to go or the code is appreciated!
And my code so far:
$(document).ready(function() {
$(document).on('blur change', '.estExpns input', esttotal);
$(document).on('blur change', '.expns input', calcFunding);
});
function parseNumber(n) {
var f = parseFloat(n); //Convert to float number.
return isNaN(f) ? 0 : f; //treat invalid input as 0;
};
// Estimated Expenses Summation
function esttotal() {
var s = 0;
$('.estExpns input').each(function () {
s += parseNumber($(this).val());
});
$('.estTotal input').val(s);
};
// Calculate funding totals and post processing options based on checkbox values
function calcFunding() {
var g = 0;
var d = 0;
var t = '';
if ( $('.fundSource input').val('Federal Grant') == true){
$('.expns tbody tr').each(function () {
tn = $(this).find('.grantName input').val($(this).find('.grantName option:selected').val());
$('.ttlName input').val(t);
})
// Sum all the federal expenses
d += parseNumber($('.estExpns input').val());
$('.fedTotal input').val(d);
} else {
// Sum all the general expenses
g += parseNumber($('.estExpns input').val());
$('.genTotal input').val(g);
}
};
Thank you in advance.