Search these areas:
Help
Support Forums
Product Info



-Introduction
-DataWeb: What's New
-Creating an Application
-The DataWeb Designer
-Application Management
-Data Tables
-Data Tables
-Views
-Templates
-Components
-Data Analysis
-Members
-Security
-Importing
-Exporting
-FTP
-JavaScript
-Object Model
-Full-Text Search
-Domain and Email Hosting
-HotBlock Modules
-Account Management
-Glossary
-New Responsive UI Module





DataWeb Help
Support Forums
Tutorial
Script Library
Knowledge Base

Home > Support

Script Library

  Standard number formatting in script.
 
  chubbard posted this script:
  My script function returns a number. I'd like to apply a STANDARD ( 1,453.57 ) format to that number when I display it.

//
// apply STANDARD format to NUM
// return as a string
//
public function formatNumber( num )
    {
    var str = num.toString();
    var idxDot = str.indexOf('.');
    var idxMin = 0;
    if (idxDot == -1)
        idxDot = str.length;

    if (str.charAt(0) == '-')
        idxMin = 1;

    for ( idxDot -= 3; idxDot > idxMin; idxDot -= 3)
        str = str.subString( 0, idxDot ) + "," + str.subString( idxDot );

    return str;
    }
 
Affiliate | Partner | Terms of Use | Privacy Policy | Contact Us | Pricing | Bring DataWeb In-House    
DataWeb, 720 North 10th Street, A #145, Renton, Washington 98057 *425-583-5970* Fax 484-770-4706* Email Us