请修改印度数字格式的Java脚本 [英] Please modify the java script for number in indian number format

查看:62
本文介绍了请修改印度数字格式的Java脚本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

hi ..
检查以下代码..

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>



以上功能的结果显示如下123,123,123.00
但是我想要这种格式12,12,12,12,123.00,即印度货币格式..



The result of the above function is displaying like this 123,123,123.00
but i want in this format 12,12,12,12,123.00 i.e indian currency format..

推荐答案

1''+'',''+''
1'' + '','' + ''


2''); } v =整体+子; 返回v; } </script>
2''); } v = whole + sub; return v; } </script>



以上功能的结果显示如下123,123,123.00
但是我想要这种格式的12,12,12,12,123.00,即印度货币格式..



The result of the above function is displaying like this 123,123,123.00
but i want in this format 12,12,12,12,123.00 i.e indian currency format..


尝试使用此格式
try this its working
 function changeNo (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{2})/;
if(parseInt(whole)>999)
{
var whole1=whole.substring(whole.length-3);
var whole2=whole.substring(0,whole.length-3);
while (r.test(whole2))
{
whole2 = whole2.replace(r, ''


这篇关于请修改印度数字格式的Java脚本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆