...

View Full Version : How to convert a currency format to a decimal float value?



NinjaTurtle
03-17-2005, 04:35 PM
i want to do a simple calculation: Quantity * Unitprice = Total, three textboxes.
But the UnitPrice will auto convert to currency format and display as "1,200.50" when user try to enter the value 1200.50. problem is the value with comma cannot do multiply... parseFloat is not working too.



document.form1.UnitPrice.value=ConvertCurrency(document.form1.UnitPrice.value)
document.form1.Total.value=document.form1.Quantity.value*document.form1.UnitPrice.value

NinjaTurtle
03-17-2005, 04:40 PM
i found the solution:

abc=parseFloat(document.form1.UnitPrice.value.replace(",", ""))
document.form1.Total.value=document.form1.Quantity.value*abc



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum