Okay, i have this code which is working fine to a specific point.
$(document).ready(function(){
var val1 = +$(".charge").val();
var val2 = +$(".fee").val();
var val3 = +$(".loadrate").val();
$("#finalrate").val(val1-val2+val3);
$(".financeinput").keyup.each(function(){
var val1 = +$(".charge").val();
var val2 = +$(".fee").val();
var val3 = +$(".loadrate").val();
var initial = $("#finalrate").val();
$("#finalrate").val(val1-val2+val3);
var second = $("#finalrate").val();
if(initial < second){
$("#finalrate").removeClass("redardown").addClass("greenarup");
}
if(initial > second){
$("#finalrate").removeClass("greenarup").addClass("redardown");
}
if(initial = second){
}
});
});
I have multiple fields with class ".charge" and multiple fields with class ".fee" but the code here is getting only the values of the first fields with that class, while i need all of them to be calculated. I know this must be very easy, but i am fairly new to javascript.