Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    Regular Coder
    Join Date
    Jun 2002
    Posts
    358
    Thanks
    2
    Thanked 0 Times in 0 Posts

    How to convert a currency format to a decimal float value?

    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.

    Code:
    	document.form1.UnitPrice.value=ConvertCurrency(document.form1.UnitPrice.value)	
    	document.form1.Total.value=document.form1.Quantity.value*document.form1.UnitPrice.value
    Thanks.
    =====================================================
    From NinjaTurtle
    ++http://ohmygoh.blogspot.com|http://technology.ohmygoh.com++

  • #2
    Regular Coder
    Join Date
    Jun 2002
    Posts
    358
    Thanks
    2
    Thanked 0 Times in 0 Posts
    i found the solution:

    abc=parseFloat(document.form1.UnitPrice.value.replace(",", ""))
    document.form1.Total.value=document.form1.Quantity.value*abc
    Thanks.
    =====================================================
    From NinjaTurtle
    ++http://ohmygoh.blogspot.com|http://technology.ohmygoh.com++


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •