therealwesfoster Posted January 16, 2008 Share Posted January 16, 2008 I'm wanting to restrice how long a dynamic money amount can be. For instance, I want $2.4200000000000004 to be $2.42. I know that you can do this in php using the sprintf function, but how would you go about doing this in javascript? Thanks Quote Link to comment Share on other sites More sharing options...
phpQuestioner Posted January 16, 2008 Share Posted January 16, 2008 <script language="javascript"> var original=2.4200000000000004; var change=Math.round(original*100)/100; alert("$"+change+""); // you can take this our; just for demo purposes </script> Quote Link to comment Share on other sites More sharing options...
therealwesfoster Posted January 16, 2008 Author Share Posted January 16, 2008 Much appreciated. Worked like a charm. So simple. Thanks Quote Link to comment Share on other sites More sharing options...
phpQuestioner Posted January 16, 2008 Share Posted January 16, 2008 your welcome Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.