How to Convert Text to Number When Comma's are entered
Last Post 07-02-2013 05:47 AM by Ryan Bakerink. 1 Replies.
AddThis - Bookmarking and Sharing Button
Author Messages Not Resolved
lbryantUser is Offline
new to the springs
new to the springs
Posts:3
Avatar

--
07-02-2013 04:17 AM
    I have the following script in the Client Side event for a grand total.  Everything works great until we had a user enter values in our text boxes with commas.  Now the grand total won't calculate right.  

    How do I edit the formula to ensure if a user does/doesn't enter a value in a text box with a comma that the grand total will still display correctly?

    $(GrandTotalHidden) = formatCurrency(eval(parseFloat($(Wheat)) + parseFloat($(Seed)) + parseFloat($(LPG)) + parseFloat($(Corn)) + parseFloat($(Chemicals)) + parseFloat($(Petroleum)) + parseFloat($(SoyBeans)) + parseFloat($(Feed)) + parseFloat($(Hardware)) + parseFloat($(MiloSorghum)) + parseFloat($(Fertilizer)) + parseFloat($(LivestockPoultry)) + parseFloat($(Oats)) + parseFloat($(Lumber)) + parseFloat($(Barley)) + parseFloat($(DieselFuel)) + parseFloat($(Other)) + parseFloat($(Other2))))
    Ryan BakerinkUser is Offline
    river guide
    river guide
    Posts:1900
    Avatar

    --
    07-02-2013 05:47 AM
    Hello,

    You'll need to do 1 of the two things:

    1.) Strip out all non-numeric information when inputted by user using JavaScript

    or

    2.) Inside of your calculation, use a replace statement to remove all commas


    This blog post has a JavaScript function that searches for single and double quotes and replaces it with other characters.
    http://www.datasprings.com/news/blo...ble-quotes

    You can re-use this function, to look for commas and replace with nothing(which will act as just removing the comma).

    You need to focus on stripping any non-numeric characters from your values before beginning calculating.

    Please let us know if you have any questions.

    Thanks,

    Ryan


    ---
  • film izle
  • 720 izle
  • film
  • sinema izle
  • film makinesi
  • T�rk�e dublaj film
  • film izle
  • film izle
  • baglan film izle
  • sinema izle
  • 1080 film izle
  • film mercegi