Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Uncaught ReferenceError: Invalid left-hand side in assignment error

I'm receiving the following error:

"Uncaught ReferenceError: Invalid left-hand side in assignment"

From this code:

if (!oPrismaticMaterial = "") {
    for (var i = 0; i < oPrismaticMaterial.length; i++) {
        if (oPrismaticMaterial[i].checked) {
            oPrismaticMaterial[i].checked = true;
            radioChecked = true;
            break;
        }
    }
    if (!radioChecked) {
        bValidated = false;
        sErrorMessage += "Please select grades and metal\n";
    }
}
like image 963
SquishyFresh Avatar asked Dec 19 '25 20:12

SquishyFresh


2 Answers

You should be using != instead of = in your if statement.

== is a comparison for equal to, != is a comparison for not equal to, = is for assignment.

Therefore you need to change your if statement from:

if (!oPrismaticMaterial = "")

to

if (oPrismaticMaterial != "")

like image 72
dsgriffin Avatar answered Dec 21 '25 10:12

dsgriffin


Maybe the "=" has to be an "===", it won't work for "==".

like image 25
Chalk Avatar answered Dec 21 '25 09:12

Chalk