asp.net - javascript calculation not giving desired out put -
i have following code
function calculatevat() { var vat = null;var amount=null; vat = document.getelementbyid("hiddenvat").value; amount = document.getelementbyid("numtxt_itemcost").value; var total = parseint(amount)* parseint(vat) / 100 ; document.getelementbyid("txt_total_text").value = total; }
here calculating vat price according amount price
e.g vat value 13.5
if input 1780 on numtxt_itemcost field should give output 240.30
but when run programme puting value 1780 on numtxt_itemcost field
it shows 231.4 wrong output
help please urgent!!
you should use parsefloat
instead:
parsefloat(1780)* parsefloat(13.5) / 100 //240.3
when use parseint
, decimals stripped off.
Comments
Post a Comment