Question
How to return 0 in JavaScript
I use the javascript below to calculate the differance between 2 values. It works fine unless the value is 0, then it displays nothing. Is it posible to make it display 0 if the 2 values are the same?
// Get the values from the textboxes
var value1 = parseFloat(this.getField("RealEstate_Loan_1").value) || 0;
var value2 = parseFloat(this.getField("RealEstate_MarketValue_1").value) || 0;
// Perform the subtraction
var result = value2 - value1;
// Set the result in another field (e.g., ResultBox)
this.getField("RealEstate_NetValue_1").value = result.toFixed(2);