Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/asp.net/30.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何在javascript中将整数类型转换为金额类型?_Javascript_Asp.net - Fatal编程技术网

如何在javascript中将整数类型转换为金额类型?

如何在javascript中将整数类型转换为金额类型?,javascript,asp.net,Javascript,Asp.net,可能重复: 在JavaScript中,我访问了如下变量: amount= document.getElementById('<%= DataItemValue1.ClientID%>').firstChild.nodeValue; amount=document.getElementById(“”).firstChild.nodeValue; 现在,如果金额是10945,我希望它是$10945;如果1098为1098美元 如何在javascript中执行此操作并将其传递给标签

可能重复:

在JavaScript中,我访问了如下变量:

amount= document.getElementById('<%= DataItemValue1.ClientID%>').firstChild.nodeValue;
amount=document.getElementById(“”).firstChild.nodeValue;
现在,如果金额是
10945
,我希望它是
$10945
;如果
1098
1098美元

如何在javascript中执行此操作并将其传递给标签

非常感谢。

使用此功能

function amount( value ) {
    value = value.toString();
    var o = '';
    do {
        var s = value.substr( -3 );
        value = value.substr( 0, value.length - 3 );
        o = (value.length?',':'')+s+o;
    } while( value.length );
    return '$'+o;
}

谢谢你,弗雷德里克,这真的很管用,一句话也没换。