RaceBase
RaceBase

Reputation: 18848

Javascript If condition check on window load

I am facing a js error. But what I see is js is perfectly fine

window.onload = function() {
    var check = 'false';
    if (check == 'true') {
        var disableFlowCheck = ; //this will not come in case of fail
        if (disableFlowCheck && document.getElementById("submitlin")) {
            document.getElementById("submitlin").disabled = true;
        }
    }
}

This looks pretty good. this condition shouldn't be executed at all. But What i see, the executing the if condition is getting executed, which shouldn't be.

Upvotes: 0

Views: 3347

Answers (1)

nanobash
nanobash

Reputation: 5500

var disableFlowCheck = ; //This is syntax Error

// change to 

var disableFlowCheck = "";

// Or 

var disableFlowCheck = true;

Note: You have to assign variable to some value , or just define to any type variable you want (array,boolean) or just remove it

Upvotes: 3

Related Questions