Facility Control

 View Only
  • 1.  Number to currency

    Posted 11-14-2018 13:41
    Hi
    I have a number that I want formatted into currency string. I have tried toLocaleString, and although it doesn't complain it can't find that function, it actually does nothing!
    How can I convert a number to a currency formatted string?

    Thanks
    Simon


  • 2.  RE: Number to currency

    Posted 11-14-2018 17:57

    Use toFixed on your numeric value.

    <abs contexttype="opengear" gridsize="20" id="_top">
       <meta>
          <params>
             <param access="1" constraint="0.0;100.0;0.0;100.0;1" constrainttype="INT_STEP_RANGE" name="num" oid="num" precision="0" type="INT32" value="0" widget="spinner"/>
          </params>
       </meta>
       <param expand="true" height="60" left="40" oid="num" runtasksonload="true" top="40" width="200">
          <task tasktype="ogscript">ogscript.rename('cur', '$' + params.getValue('num', 0).toFixed(2));</task>
       </param>
       <label height="80" id="cur" left="260" style="txt-align:west" top="40" width="200"/>
    </abs>

    #DashBoard


  • 3.  RE: Number to currency

    Posted 11-15-2018 10:05
    Thanks James
    But what I need is also the number formatting so it would read $1,400,231 for example. I have now written a routine to do it!
    #DashBoard