如何将字符串值转换为Parsefloat [英] How Do I Convert String Value To Parsefloat

查看:133
本文介绍了如何将字符串值转换为Parsefloat的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图计算may代码中的总金额和总增值税百分比,但它给了我nun结果。



这里是我的jQuery代码。

I m trying to calculate total amount and total vat percentage in may code, but its gives me nun result.

here is my jQuery code.

function getPackagevalues()
    {
        debugger;
        var total=0;
        var vattot=0;
        alert('inclide getPackagevalues');
        $("#mytab1").find("tbody tr").each(function()
        {

            if($(this).find("td:eq(8)").text()!=null && $(this).find("td:eq(8)").text()!="")
            {
                var val=parseInt($(this).find("td:eq(8)").text(),10);
                total+=val;
            }
            if($(this).find("td:eq(7)").text()!=null && $(this).find("td:eq(7)").text()!="")
            {
                var val2=parseInt($(this).find("td:eq(7)").text(),10);
                vattot+=val2;
            }
        });

        document.getElementById("netamt").value=total.toFixed(2);
        document.getElementById("vattotal").value=vattot.toFixed(2);
    }





在这个结果中它给出的是nan。任何人请帮我解决这个问题。

提前感谢



In this result it gives is nan. any one please help me to solve this.
thanks in advance

推荐答案

#mytab1)。find( tbody tr)。each( function ()
{

if
("#mytab1").find("tbody tr").each(function() { if(


this )。find( td:eq(8))。text()!= null &&
(this).find("td:eq(8)").text()!=null &&


this )。find( td:eq(8))。text()!=
{
var val = parseInt
(this).find("td:eq(8)").text()!="") { var val=parseInt(


这篇关于如何将字符串值转换为Parsefloat的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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