Javascript 两数相除保留两位小数点

来源:互联网 发布:数据段字节变量 编辑:程序博客网 时间:2024/06/01 10:53

toFixed(2)


function txtGXJb_Onblur(obj)
    {
        var objID=obj.id;
        
        var objGXSjID = objID.replace("txtGXJb","txtGXSj");
        
        if(document.getElementById(objGXSjID).value =="")
        {
            window.alert("当年度累计实际完成  不能为空!");
            document.getElementById(objGXSjID).focus();
            return;
        }
        
        
        if(document.getElementById(objID).value =="")
        {
            document.getElementById("jbmb").innerText="";
            //window.alert("当年度累计基本目标  不能为空!");
            return;
        }
        
        var a;
        var b;
        
         a=parseFloat(document.getElementById(objGXSjID).value);
         b=parseFloat(document.getElementById(objID).value);
         document.getElementById("jbmb").value=(a/b).toFixed(2);
    }

原创粉丝点击