未捕获的TypeError:无法读取未定义的js的属性'toString'

时间:2017-04-25 14:46:51

标签: javascript jquery uncaught-typeerror

相同的代码在

下面运行

当我尝试执行第一个函数Uncaught TypeError时:无法读取未定义的属性'toString' 但第二个也是有效的

https://jsfiddle.net/d355ogv0/2/

关于加载变量:

    var global_min_ana = 0;
var  global_min_kusurat = 0+''+0;
var durrum = 0;

问题:

$(document).on("click", "[id^=pay_sil]", function () {

if(durrum==0)
{
    console.log(global_min_ana.toString().length);
    var global_min_ana = global_min_ana.toString().substr(0,global_min_ana.toString().length -1); //<---- PROBLEM
    var totalite = global_min_ana + '.' + global_min_kusurat;
    $('#odeme_kesilen_tutar').text(totalite);
$('#odeme_kesilen_tutar_go').val(totalite);
}
else
{
console.log(global_min_kusurat.toString().length);
    var global_min_kusurat = global_min_kusurat.toString().substr(0,global_min_kusurat.toString().length -1);
    var totalite = global_min_ana + '.' + global_min_kusurat;
    $('#odeme_kesilen_tutar').text(totalite);
$('#odeme_kesilen_tutar_go').val(totalite);
}

                        });







$(document).on("click", "[id^=payday_]", function () {
    var ziggs=$(this).data("paparey");


var toplami = $('#odeme_toplam_tutar_go').val();
var degger;




        if(ziggs=="."){
            durrum = 1;
        }           
        else
        {

            if(durrum==0 && global_min_ana==0)
            {
            global_min_ana=ziggs;
            console.log(global_min_ana);
            }
            else if(durrum==0 && global_min_ana!=0)
            {
                global_min_ana= global_min_ana + '' + ziggs;
                console.log(global_min_ana);
            }
            else if(durrum==1 && global_min_kusurat==0+''+0 && global_min_kusurat.toString().length<=2)
            {
                global_min_kusurat = ziggs;
                console.log(global_min_kusurat);
            }
            else if(durrum==1 && global_min_kusurat!=0+''+0 && global_min_kusurat.toString().length<=1)
            {
                global_min_kusurat= global_min_kusurat + '' + ziggs;
                console.log(global_min_kusurat);
            }
            else
            {
                alert('WOW');
                console.log(global_min_kusurat.toString().length);
            }
            var totalite = global_min_ana + '.' + global_min_kusurat;
            console.log(totalite + ' : totalite.');
            console.log(toplami + ' : toplami.');
        if(totalite>toplami){
            totalite = toplami;
        }
        else 
        {

        }
        }

$('#odeme_kesilen_tutar').text(totalite);
$('#odeme_kesilen_tutar_go').val(totalite);

}); 

感谢帮助我的头灼烧

https://jsfiddle.net/d355ogv0/2/

0 个答案:

没有答案