If/Else statement for hiding/showing fields using calculate button

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”);
}

 

This site will teach you how to build a WordPress website for beginners. We will cover everything from installing WordPress to adding pages, posts, and images to your site. You will learn how to customize your site with themes and plugins, as well as how to market your site online.

Buy WordPress Transfer