So I look for answer similar to mine on slackoverflow didn't find anything similar to my problem. I had an issue that the decimal places for my variable below weren't showing 2 decimal places
1) max (which now work) 2) fees (the problem im having)
so I used toFixed on one of the var Max and it works :). But the thing is for using toFixed, toFixed() specifically turns a number into a string. So once the variable max is already a string, calling ' toFixed() ' on it again is an invalid operation. Cause when I tried to use it on "fees"
var max = (principal/2)-fees;
From the function, it wouldn't work. Even if I made a new variable like:
var Test = fees.toFixed(2)
it still wouldn't work from the explanation i explain above and using https://repl.it/languages to help me. I found about Math.round(fees) as you see below but it gets rid of the decimal and show the whole number only. (the $8 is the fees variable from the code below.)
Is there some way i can fix the fees variable to show 2 decimal places OR do what im doing below and make a new var = to fees and use some code I never heard of. (still learning about this) thanks
<script>
function CollFee(input, principal, fees){
var max = ( (principal/2)-fees ).toFixed(2);
var test = Math.round(fees);
//var input = this.value;
//alert(input);
if(input.value > max){
input.value = '';
var text = 'Collection Fee is too high, the total of all collection fees can only be 50% of the Original Principal.';
text = text + ' Current fee on account is $' +test+ '. THE Maximum additional fee allowed is $' +max;
alert(text);
//document.getElementById('collfee_<?php echo $dbid; ?>').value = '';
//input.value = '';
}
};
</script>