Side by Side Ignoring Decimals | XM Community
Skip to main content

I have a side-by-side table that calculates inputs and provides a total. What I can’t seem to get to work is the ability to calculate decimals. It always seems to ignore it. I’ve been trying to replace: 


function getVal(val){ var num = parseInt(val); if(isNaN(num)) {num = 0;} return num;};

 

With both: 
function getDouble(val){ var num = parseInt(val); if(isNaN(num)) {num = 0;} return num;};
function getFloat(val){ var num = parseInt(val); if(isNaN(num)) {num = 0;} return num;};
 

But it will still treat the inputs as integers or completely break and cause the side-by-side to do nothing. 

A lot of my code is from a user named bstrahin in their post linked here: 

The only difference is that I’m multiplying between two columns, the color changes depending on the value for the grand total, and I have two different grand totals. Any help will be greatly appreciated, as I can’t determine why this issue occurs.

 

 

parseInt seems to be the issue. Use the float type instead.


Something like below

function getFloat(val) { var num = parseFloat(val); // Use parseFloat to handle decimal values if (isNaN(num)) { num = 0; } return num; }

 


Something like below

function getFloat(val) { var num = parseFloat(val); // Use parseFloat to handle decimal values if (isNaN(num)) { num = 0; } return num; }

 

I’m so upset that I wasn’t able to notice the “parseInt” in my “function getFloat” and “function getDouble”

Thank you for pointing it out to me! 


Leave a Reply