Susan
Susan

Reputation: 1832

Logical && operator

Having an unpredicted outcome using the && logical operator. If I link more than 2 expressions, the if clause fails. Is there some limit to the number of expressions that can be concatenated using &&?

            if (tTellerProN.checked && tCareProN.checked && tSalesProN.checked) {
                $(flListEmpty).empty();
                $(flListEmpty).append($('<option></option>').val(0).html("Select Role"));
                $('.fl_list1 .list4').each(function (index) {
                    $(flListEmpty).append($('<option> </option>').val(index).html($(this).text()));
                })
            }

Upvotes: 0

Views: 607

Answers (4)

Andy
Andy

Reputation: 30135

i made a test case here with both && and ||: http://jsfiddle.net/VcmCM/

Upvotes: 0

Terry
Terry

Reputation: 14219

&& is not a jQuery operator, it is Javascript. jQuery is a library that builds on Javascript.

I'm not sure what the ** is in your IF statment but this code works:

var x = true;
var y = true;
var z = true;

alert(x && y && z);  // true
alert(x && y && !z); // false

I would alert the values of your 3 .checked parameters and make sure they are being set as you expected.

Upvotes: 4

Blindy
Blindy

Reputation: 67362

No, there is no limit.

However looking at your code (what little there is of it and with such descriptive variable names used), I would venture a guess that you actually mean ||, not &&.

Upvotes: 2

bfavaretto
bfavaretto

Reputation: 71908

No, there is no limit. Your expression requires that all three checked values are true, otherwise it will return false. One of them must be false (or not true), that's why your if is failing.

For the record: && is part of the javascript language, not the jQuery library.

Upvotes: 2

Related Questions