Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Java
  4. Please modify the java script for number in indian number format

Please modify the java script for number in indian number format

Scheduled Pinned Locked Moved Java
javajavascripttoolsquestion
7 Posts 5 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • V Offline
    V Offline
    vinu 1111
    wrote on last edited by
    #1

    hi.. check the following code.. <script type="text/javascript"> var indMoney = function (v) { v = (Math.round((v - 0) * 100)) / 100; v = (v == Math.floor(v)) ? v + ".00" : ((v * 10 == Math.floor(v * 10)) ? v + "0" : v); v = String(v); var ps = v.split('.'), whole = ps[0], sub = ps[1] ? '.' + ps[1] : '.00', r = /(\d+)(\d{3})/; while (r.test(whole)) { whole = whole.replace(r, '$1' + ',' + '$2'); } v = whole + sub; return v; } </script> The result of the above function is displaying like this 123,123,123.00 but i want in this format 12,31,23,123.00 i.e indian currency format..

    L P T R 4 Replies Last reply
    0
    • V vinu 1111

      hi.. check the following code.. <script type="text/javascript"> var indMoney = function (v) { v = (Math.round((v - 0) * 100)) / 100; v = (v == Math.floor(v)) ? v + ".00" : ((v * 10 == Math.floor(v * 10)) ? v + "0" : v); v = String(v); var ps = v.split('.'), whole = ps[0], sub = ps[1] ? '.' + ps[1] : '.00', r = /(\d+)(\d{3})/; while (r.test(whole)) { whole = whole.replace(r, '$1' + ',' + '$2'); } v = whole + sub; return v; } </script> The result of the above function is displaying like this 123,123,123.00 but i want in this format 12,31,23,123.00 i.e indian currency format..

      L Offline
      L Offline
      Lost User
      wrote on last edited by
      #2

      This is the Java forum, Javascript is next one down.

      I must get a clever new signature for 2011.

      P 1 Reply Last reply
      0
      • V vinu 1111

        hi.. check the following code.. <script type="text/javascript"> var indMoney = function (v) { v = (Math.round((v - 0) * 100)) / 100; v = (v == Math.floor(v)) ? v + ".00" : ((v * 10 == Math.floor(v * 10)) ? v + "0" : v); v = String(v); var ps = v.split('.'), whole = ps[0], sub = ps[1] ? '.' + ps[1] : '.00', r = /(\d+)(\d{3})/; while (r.test(whole)) { whole = whole.replace(r, '$1' + ',' + '$2'); } v = whole + sub; return v; } </script> The result of the above function is displaying like this 123,123,123.00 but i want in this format 12,31,23,123.00 i.e indian currency format..

        P Offline
        P Offline
        Pravin Patil Mumbai
        wrote on last edited by
        #3

        You posted the same question in Questions section. Refer to http://www.codeproject.com/Questions/162106/Please-modify-the-java-script-for-number-in-indian.aspx[^]

        1 Reply Last reply
        0
        • L Lost User

          This is the Java forum, Javascript is next one down.

          I must get a clever new signature for 2011.

          P Offline
          P Offline
          Pravin Patil Mumbai
          wrote on last edited by
          #4

          More than that he has asked the same question in the Questions section too...lol

          1 Reply Last reply
          0
          • V vinu 1111

            hi.. check the following code.. <script type="text/javascript"> var indMoney = function (v) { v = (Math.round((v - 0) * 100)) / 100; v = (v == Math.floor(v)) ? v + ".00" : ((v * 10 == Math.floor(v * 10)) ? v + "0" : v); v = String(v); var ps = v.split('.'), whole = ps[0], sub = ps[1] ? '.' + ps[1] : '.00', r = /(\d+)(\d{3})/; while (r.test(whole)) { whole = whole.replace(r, '$1' + ',' + '$2'); } v = whole + sub; return v; } </script> The result of the above function is displaying like this 123,123,123.00 but i want in this format 12,31,23,123.00 i.e indian currency format..

            T Offline
            T Offline
            TorstenH
            wrote on last edited by
            #5

            WTF - damn, you indian programmers like to get penalized - ain't ya! NumberFormat @ Oracle JavaDoc[^] That's how we do it in Java - pretty simple. regards Torsten

            I never finish anyth...

            L 1 Reply Last reply
            0
            • T TorstenH

              WTF - damn, you indian programmers like to get penalized - ain't ya! NumberFormat @ Oracle JavaDoc[^] That's how we do it in Java - pretty simple. regards Torsten

              I never finish anyth...

              L Offline
              L Offline
              Lost User
              wrote on last edited by
              #6

              Except his question is regarding Javascript.

              I must get a clever new signature for 2011.

              1 Reply Last reply
              0
              • V vinu 1111

                hi.. check the following code.. <script type="text/javascript"> var indMoney = function (v) { v = (Math.round((v - 0) * 100)) / 100; v = (v == Math.floor(v)) ? v + ".00" : ((v * 10 == Math.floor(v * 10)) ? v + "0" : v); v = String(v); var ps = v.split('.'), whole = ps[0], sub = ps[1] ? '.' + ps[1] : '.00', r = /(\d+)(\d{3})/; while (r.test(whole)) { whole = whole.replace(r, '$1' + ',' + '$2'); } v = whole + sub; return v; } </script> The result of the above function is displaying like this 123,123,123.00 but i want in this format 12,31,23,123.00 i.e indian currency format..

                R Offline
                R Offline
                RaviRanjanKr
                wrote on last edited by
                #7

                You should put your code in code block by using "pre" tag it makes readability of code. and next I am suggesting you as same as Richard suggest you should move your question to there-[JavaScript Forum][^] for quick response :)

                1 Reply Last reply
                0
                Reply
                • Reply as topic
                Log in to reply
                • Oldest to Newest
                • Newest to Oldest
                • Most Votes


                • Login

                • Don't have an account? Register

                • Login or register to search.
                • First post
                  Last post
                0
                • Categories
                • Recent
                • Tags
                • Popular
                • World
                • Users
                • Groups