Hi, I have written a javascript as follows: function abc(str){ alert("In abc") var str1=false if(condition1){ alert("in condition1) str1=true //code } if(condition2){ alert("in condition2") str1=true //code } if(str1==false){ alert("success") xyz(str) } } function xyz(str){ //code } If condition1 or condition2 is true i am getting the respective alert messages. But am not getting the alert message for the last if even if the condition (str1==false) satisfies to be true. I am not able to find out the reason for this. Please help me out.
It works ok when I test it. I just copy/pasted your code, and entered some simple condition1 and condition2 values, and works ok. Make sure you haven't made some mistake in code in the parts you left out from the example here, because this part works ok.
just tested your script following conditions function abc(str){ alert("In abc") x=5; var str1=false if(x==1){ alert("in condition1") str1=true; //code } if(x==2){ alert("in condition2") str1=true //code } if(str1==false){ alert("success") xyz(str) } } function xyz(str){ alert(str); } abc('hello'); //x==1; // went to condition 1 //x==2; // went to condition 2 // x==5; // went to condition false Script just works fine thanks
this line is your error.. alert("in condition1) Code (markup): it should be.. alert("in condition1") Code (markup):