Hi everyone,
There's a form in which we have 2 fields that get their value from a DB lookup. These values are always integers. We require to substract these two values (the higher one from the lower one). Using the examples in the help files, I have the following code:
$(document).ready(function () { $('.LPD').change(function () { var FPD = parseNumber($('.FPD').val()); var LPD = parseNumber($('.LPD').val()); var PayC = 0; PayC = (LPD-FPD+1); $('.Paycheck input').val(PayC); }); function parseNumber(n) { var f = parseFloat(n); //Convert to float number. return isNaN(f) ? 0 : f; //treat invalid input as 0; } });
Where LPD is the higher value and last one to be changed. FPD is the lowest one and Paycheck is the field where we're showing the value.
I have tried bypassing the parseNumber() function and using the built in parseInt() value but it didn't work.
The interesting part is that the values of LPD and FPD are always '0', no matter what value is added. I've even changed the field type to be number, and removing the lookup rule by explicitly adding a number as a value, and even then it returns 0 as value.
Am I missing something here?