I do have a working example. So this code has 3 different parts. The first part obtains inputed values from number fields, then calculates those numbers and puts them into another number field. To keep the user from making math mistakes.
The Second part parses those inputs to a decimal value (I had an issue with NaN)
The third part deals with the price field and based on the drop down value I gave a predetermined value that was automatically inputed into the price field. I hope this gives you a direction on how to proceed.
$(document).ready(function () {
var m1, m2, m3, m4, m5, m6, m7, y1, y2, y3, y4, y5, y6, y7, mt, yt, D, EM;
if ($('#form_xxxx').length) {
$(document).change(function () {
//Monthly and Yearly Income
m1 = $('#element_157').val();
m2 = $('#element_158').val();
m3 = $('#element_34').val();
m4 = $('#element_39').val();
m5 = $('#element_41').val();
m6 = $('#element_43').val();
m7 = $('#element_45').val();
y1 = $('#element_25').val();
y2 = $('#element_31').val();
y3 = $('#element_35').val();
y4 = $('#element_38').val();
y5 = $('#element_40').val();
y6 = $('#element_42').val();
y7 = $('#element_44').val();
//Calculate Monthly and Yearly Income
mt = parseInput(m1) + parseInput(m2) + parseInput(m3) + parseInput(m4) + parseInput(m5) + parseInput(m6) + parseInput(m7);
$('#element_159').val(parseInput(mt).toFixed(2));
yt = parseInput(y1) + parseInput(y2) + parseInput(y3) + parseInput(y4) + parseInput(y5) + parseInput(y6) + parseInput(y7);
$('#element_46').val(parseInput(yt).toFixed(2));
D = $('#element_71').val();
// Calculate Income - Expenses
EM = parseInput(mt) - parseInput(D);
$('#element_87').val(parseInput(EM).toFixed(2));
});
}
});
// Default values to 2 decimal points
function parseInput(val) {
val = parseFloat(val, 10);
if(isNaN(val)) {
return 0;
} else {
return val;
}
}
// Drop down Tuition Prices
$(function () {
$("#element_162").change(function () {
var tuition = $(this).val();
if (tuition === '1'){
$("#element_15_1").val('2199');
$("#element_15_2").val('50');
} else if (tuition === '2'){
$("#element_15_1").val('4399');
$("#element_15_2").val('00');
} else if (tuition === '3'){
$("#element_15_1").val('4399');
$("#element_15_2").val('00');
} else if (tuition === '7'){
$("#element_15_1").val('6210');
$("#element_15_2").val('00');
} else if (tuition === '6'){
$("#element_15_1").val('7220');
$("#element_15_2").val('00');
} else if (tuition === '5'){
$("#element_15_1").val('7750');
$("#element_15_2").val('00');
} else if (tuition === '4'){
$("#element_15_1").val('8300');
$("#element_15_2").val('00');
}
});
});