views:

380

answers:

3

For example. there are 3 variables, 1 is a must, 2 and 3 are eithers so 3 can be false as long as 1 and 2 are true, 2 can be false as long as 1 and 3 are true.

if(xmlhttp.responseText.indexOf("type:SearchList~")>=0 && (obj == "hDrop" || obj == "iDrop")){
}

Isn't working for me

Can anyone spot the problem?

+1  A: 

You code is written correctly but it may be there are error in data you compare with so please trace the data and then check that it execute the condition correctly you can trace using alert(data);

Ahmy
+3  A: 

I built a truth table of your conditions:

1 2 3 R
-------
0 X X 0
1 0 0 0
1 1 X 1
1 X 1 1

This resolves to 1 && (2 || 3), so something else is wrong.

Ignacio Vazquez-Abrams
+2  A: 

No problem with your script that I can spot. This very simple test validates it:

var a = "yes";
var b = "no2";
var c = true;
alert(c && (a == "yes" || b == 'no'));

Check the values of 'obj'. Is it a string?

nivhab
Ugh found out I had switched out my variable earlier on with a dom replacement which didn't contain the string I needed any more. All is fixed now :D cheers
Supernovah