Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/68.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
Jquery 以货币格式转换数据库的输出_Jquery_Html_Asp.net - Fatal编程技术网

Jquery 以货币格式转换数据库的输出

Jquery 以货币格式转换数据库的输出,jquery,html,asp.net,Jquery,Html,Asp.net,嗨,我有一个输出总成本的表格单元格。现在,它只是写在正常的数字,即234344我想改变它,以便它可以显示货币格式,即3345美元,1.00 <td><input type="text" class="" id="totalCost" name="totalCose" value="{{=totalCost}}" /><td/> 我可以使用jquery、html或asp.net中的任意一种解决方案。 我试着使用这个jquery插件,但当我从数据库中获取

嗨,我有一个输出总成本的表格单元格。现在,它只是写在正常的数字,即234344我想改变它,以便它可以显示货币格式,即3345美元,1.00

 <td><input type="text" class="" id="totalCost"  name="totalCose" value="{{=totalCost}}" /><td/>

我可以使用jquery、html或asp.net中的任意一种解决方案。 我试着使用这个jquery插件,但当我从数据库中获取值时,它对输入框有效。请让我知道浪费了很多时间,没有解决办法。谢谢

这是我用的

    function format_num(number) {
        number += '';
        x = number.split('.');
        x1 = x[0];
        x2 = x.length > 1 ? '.' + x[1] : '';
        var rgx = /(\d+)(\d{3})/;
        while (rgx.test(x1)) {
            x1 = x1.replace(rgx, '$1' + ',' + '$2');
        }
        return "$" + x1 + x2;
    }
所以

输入=100000


Output=$100000

我有一个这样的使用javascript的
document.getElementById(“currentmoney”).innerHTML=format_num(结果)