i was trying to multiply the answers of my span.
for example the value <span id="total_f">210</span>
and the btw .21 it was %21 percent so we need to make it .21 to multiply it and get the total. btw is VAT in netherlands
if you see the jquery var get_total i did multiply the mul
is my jquery wrong?
this is my jquery
$(document).ready(function(){
var sum = 0;
$('input[name=sumof]').each(function(){
sum += parseInt($(this).val());
});
$('input[name=total_f]').val(sum);
$('#total_f').text(sum);
var mul = parseInt($('input[name=total_f]').val());
var get_total = mul * parseInt($('input[name=btw]').val());
$('input[name=s_btw]').val(get_total);
$('#s_btw').text(get_total);
});
my html
<table cellpadding="5" cellspacing="0" width="100%">
<tr>
<td><strong>Sub Total</strong></td>
<td>
<?php
if ( $get_total_computation['currency'] == 'euro' ) {
$msg_tot = '€';
} elseif ( $get_total_computation['currency'] == 'usd' ) {
$msg_tot = '$';
}
echo $msg_tot;
?>
<span id="total_f"></span>
<input type="hidden" name="total_f" value="" />
</td>
</tr>
<tr>
<td>
<?
echo $get_total_computation['quo_btw'];
$get_per = explode( '%', $get_total_computation['quo_btw']);
?>
<input type="hidden" name="btw" value=".<?=$get_per[0];?>" />
</td>
<td>
<span id="s_btw"></span>
<input type="hidden" name="s_btw" value="" />
</td>
</tr>
<tr>
<td><strong>Total</strong></td>
<td><?=$btw;?></td>
</tr>
</table>
Use
parseFloatto parse values that contain decimal numbers. In your case,btwcontains the value.21for whichparseIntis in-appropriate.