I am creating a simple calculator form which based on result, will show default hidden fields. The form is set to dynamically evaluate the equations for all number fields. I also have a calculate button that I am trying to complete an onclick function for showing these default hidden fields based on the calculated result of a different field. I can seem to get this successfully working by using tools like JSfiddle… i can also use tools to validate that my js is valid.. but it still will not work as expected when adding to the calculate button onclick event area.
if i try and dramatically simplify my if/else conditional logic to to the example below, this logic will not work on the button. Result even if the value of netcashflow is higher than 0 will return neutral as a result. I am lost on why this is. I have also validated using alerts that my variable has a correct value.
var netcashflow = document.getElementById(‘fieldname26_1’).value;
if(netcashflow>0){
return alert (“positive”);
}
else {
return alert (“neutral”);
}