I am new to Javascript and I got most of this code from another Q&A on this site worked great! Only problem is that the code doesn't count the decimals! How do I get this code to count the decimals?
<table> <tr class=r1>
<th class=d1>1-24</th>
<th class=d2>25-49</th>
<th class=d2>50-99</th>
<th class=d2>100-499</th>
<th class=d2>500 = Offert</th>
<tr class=r1>
<td class=d1 id=A>99,00:-</td>
<td class=d2 id=B></td>
<td class=d2 id=C></td>
<td class=d2 id=D></td>
<td class=d2> </td> </tr>
</table>
That's the table I have to make a bracket price.
This is the Javascript:
(function(){
// put all your JavaScript in a closure so you don't pollute the global namespace
function extract_float_from_price ( price ) {
return parseFloat( price.replace(/\:*-/,'') );
}
function evaluate_savings ( ) {
var A = extract_float_from_price( $('#A').text() );
$('#B').text( parseInt(A * 0.96 ) + ':-' );
$('#C').text( parseInt(A * 0.92 ) + ':-' );
$('#D').text( parseInt(A * 0.88 ) + ':-' );
}
$( evaluate_savings ); // binds to Dom Ready
})()
Please help me get the code to show decimals for a more exact price.