jd2007 Posted August 13, 2007 Share Posted August 13, 2007 var x=2; var y=3; if ((x==3)&&(y==3)) { alert("Success !"); } else { alert("Failure."); } the above checks if x is equal to three and y is equal to three or not. if one of the conditions return false, the whole thing returns. how do i check which condition returns false ? Link to comment https://forums.phpfreaks.com/topic/64592-dynamic-if-and-else-statements/ Share on other sites More sharing options...
php_tom Posted August 13, 2007 Share Posted August 13, 2007 How about: var x=2; var y=3; if ((x==3)&&(y==3)) alert("Success !"); else { if(x==3) alert("y wasn't 3"); elseif(y==3) alert("x wasn't 3"); else alert("both x and y weren't 3"); } Is this what you wanted? Link to comment https://forums.phpfreaks.com/topic/64592-dynamic-if-and-else-statements/#findComment-322054 Share on other sites More sharing options...
jd2007 Posted August 13, 2007 Author Share Posted August 13, 2007 yes...i can do that...i want a shorter way.. Link to comment https://forums.phpfreaks.com/topic/64592-dynamic-if-and-else-statements/#findComment-322194 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.