提交后十进制格式不正确

时间:2014-12-02 16:35:57

标签: javascript jquery

我正在使用jquery开发一个项目,并且我应用了一个手动方法来处理十进制格式,例如我显示带有两个带有两个浮动数字的小数的数字,并且为了使数字更具可读性,我在数千之间使用逗号,它工作正常,但提交表单时,添加了两个零,例如:  在提交之前2500.00显示2,500.00,我创建了一个删除逗号的函数,在提交事件中,使用firebug,我确保逗号被删除,我得到:2500.00,但是当数据显示在show view /页面,我得到了250000.00 看?添加了两个零,我不知道怎么样,有我的代码:

$("#stock_stockbundle_facturefounisseur_submit").click( function() {
        $('input[id$="prixLignefacturefournisseur"]').each(function(){
            idprix = $(this).attr('id');
            prix = document.getElementById(idprix);
            if (document.getElementById(idprix).value ){
                var prixv = document.getElementById(idprix).value.replace(",","");
                document.getElementById(idprix).value = prixv;
                console.log('prixv : ',prixv);
            }
        });
        $('input[id$="totalLignefacturefournisseur"]').each(function(){
            idtotal = $(this).attr('id');
            total = document.getElementById(idtotal);
            if (document.getElementById(idtotal).value ){
                var totalv = document.getElementById(idtotal).value.replace(",","");
                document.getElementById(idtotal).value = totalv;
                console.log('total : ',totalv);
            }
        });
    });

注意:我使用Symfony2。

任何想法,如何处理这种问题? 提前谢谢!!!!

0 个答案:

没有答案